Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

We can issue CTRL+Z to suspend any jobs in Unix and then later on bring them back to life using fg or bg. I want to understand what happens to those jobs that are suspended like this ? Are they killed/terminated ? In other words what is the difference between killing and suspending a process ?

share|improve this question
    
wikipedia article should be a good place to start en.wikipedia.org/wiki/Job_control_(Unix) –  gelraen Jan 21 '13 at 18:00

3 Answers 3

up vote 6 down vote accepted

The jobs are not killed, they are suspended. They remain exactly as they are at the time of the suspension: same memory mapping, same open file, same threads, … It's just that the process sits there doing nothing until it's resumed. It's like when you pause a movie. A suspended process behaves exactly like a process that the scheduler stubbornly refuses to give CPU time to, except that the process state is recorded as suspended rather than running.

share|improve this answer

When suspend, the kernel doesn't include the process to the processor queue. When killed, the stack (memory) of the process is released.

share|improve this answer

From a user's perspective, it means that the job is paused. It will no longer use any CPU. It will, however, keep using the same amount of RAM. That is why you can bring it back to the foreground with fg and it will continue where it left off.

If you kill a job and then restart it, it will start over from scratch.

share|improve this answer
    
Weill a "suspended" job be swapped out if there is not enough ram? –  Bonsi Scott Jan 22 '13 at 18:51
    
Hmm, good point, no idea. Ask @gilles, he might know. –  terdon Jan 22 '13 at 18:55
    
Yes of course - as far as the OS is concerned, the pages allocated to a suspended or running job are the same. –  Gaius Aug 29 '13 at 12:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.