Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

beginner's Unix question:

I'm a bit confused about the purpose of suspended (Ctr+Z) commands in a unix shell. From what I gather a suspended process/command is neither in the background nor (obviously) in the foreground. However - and I'm not really sure about this but that's what my day to day fiddling indicates - a suspended process is not 'paused' as it will terminate (or at least 'finish its job') like any other. It just won't output to the terminal.

So what is the special purpose (or 'mechanics' if you prefer) of the suspended state? Why not just background and foreground?


[edit: I was wrong in my assumption that "a suspended process is not 'paused' as it will terminate (or at least 'finish its job') like any other". See the accepted answer.]

share|improve this question
up vote 2 down vote accepted

If you suspend a job using Ctrl+Z it pauses, i.e. it will not "finish its job". You can use bg to let it continue in the background (which means it might still write in stdout, but can't read from stdin). I think though that you can write a program in such a way as to ignore Ctrl+Z or handle it in some other way, not sure about that.

If on the other hand you wish to start it in the background, you can put a & after the command in the shell.

See also

share|improve this answer
That is correct - I was wrong in my assumption that "a suspended process is not 'paused' as it will terminate (or at least 'finish its job') like any other". A suspended process is truly 'paused' while a background process will execute normally. – biril Nov 15 '12 at 14:33

It is used to allow another process assume control over standard input and output. It is also used to start another process in the same shell.


While running a text editor that takes up the whole terminal you type ^Z close the editor temporarily and run a few commands (move files, change song, start another interactive program). When done, you resume editing your file by bringing the editor forward again.

share|improve this answer
Another useful example would be a chat client that takes up the whole terminal, that you wish to silence for a while while doing something else. – Ярослав Рахматуллин Nov 15 '12 at 12:32
Ok, but why is the suspended state preferable to the background state for this sort of thing? If I had some way of sending the foreground process directly to the background (without first 'suspending') why wouldn't I do that? What is the special value of 'suspended' compared to 'background'? – biril Nov 15 '12 at 12:38
You do have a way of sending a process directly to the background: command ampersand, as in apt-get install whatnot &. Alternatively you have nohup program that is different. And there is disown which will send everything that is in the background further back in the background. ^Z is convenient for processes that you want to suspend or even dis-attach from the terminal entirely after you have started them in the foreground. – Ярослав Рахматуллин Nov 15 '12 at 17:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .