What should I do when I get 'There are stopped jobs' error?

There are stopped jobs message is far, far away to be an error. It's just a notification telling you that you attempt to exit from the shell, but you have one or more suspended jobs/programs (in your case emacs which you putted in background using & at the end of your command). The system doesn't let you to exit from the shell and kill the jobs unless you mean to. You can do a couple of things in response to this message:

  • use jobs command to tell you what job(s) you have suspended
  • you can choose to add the job(s) in the foreground using fg command
  • if you don't care if the job(s) will terminate, you can just type exit again; typing exit a second time with or without an intervening jobs command will result in the termination of all suspended jobs.

To answer the second question, I will tell you that not Ubuntu or emacs behaving like this. This is a normal behavior when you put an application to run in background. In this case sudo is asking for password, but is asking in background, so you can't see this fact. To see it, you should bring back the job in foreground using fg command:

radu@Radu: ~ $ sudo emacs tet.c &
[1] 7732
radu@Radu: ~ $ # now sudo emacs run in background so you can't see nothing about what's happening
radu@Radu: ~ $ fg
[sudo] password for radu:

After this you can type Ctrl+Z to put again the job in background if you want. Then you can run again 'fg' command to bring back the job in foreground and so on.


You got the message, because system warns you about active jobs associated with your current shell.

You can list these running/stopped jobs by running: jobs,

Then you can do one of the following:

  • move last job to the foreground by: fg (opposite of bg for background),
  • run disown to remove these jobs from your current shell without killing them,
  • force logout by killing these tasks by pressing Ctrl+D twice, same as typing exit/logout twice,
  • kill these jobs manually by running: kill $(jobs -p) (add -9 for force)
  • if you disown them, and you want to still kill all stopped processes, try:

    kill $(ps wuax | awk 'NR>1 && $8 ~ "T" {print $2}')


To answer question about sudo, it won't ask you for the password, as it requires to have active terminal in order to receive the password from standard input, and by running it the background, the shell doesn't wait for the command to finish, so you don't have possibility to interact with the command.

In this case, you've 3 possibilities:

  • run command without going into background (&),
  • read the password from standard input instead of the terminal device by sudo -S e.g.

    echo mypass | sudo emacs tet.c
    
  • configure sudo to not ask for the password by: visudo command and editing sudoers file. See: Enable NOPASSWD for user


When you encounter there are stopped jobs error:

  1. typejobs--> you will see the jobs with stopped status
  2. and then type exit--> you can get out of the terminal