1 Answer
1

I think you may be confused about the job control notation. Notably "Stopped" means that a job is still alive but that its ability to process anything has been held (it is not given any time on the CPU to process anything). This is effectively a "Pause" or "Suspended" state, although that is not the correct technical term.

CtrlC does not "stop" a job, it cancels or kills it. Technically it causes an interrupt signal to be sent to the program telling it to abort what it is doing and exit immediately. Some programs will hear this signal and do some emergency clean up work on themselves before exiting. Others will not respond to the signal and are subsequently just aborted.

CtrlZ, on the other hand, "stops" a job. Again this is done with a signal, but this time it is a 'stop' instead of an 'interrupt' signal. This effectively puts it on hold and returns control to the shell, but does not actually kill the job. If you would like such a job to keep running, you can then issue a bg command to send the last stopped job to the background. It will then continue running as a background job as if you had run it with & in the first place. You may also use fg to resume the last stopped job in the foreground (allowing it to continue where it left off, and allowing you to interact with it again).

I still think that Ctrl+Z will send SIGKILL and Ctrl+C sends SIGINIT. So the Ctrl+Z would also kills the job. But from my example Ctrl+Z only Stops the job like you said. So it make me a little confused.
– neo0Jun 8 '14 at 7:58

9

@neo0 - maybe you're used to some weird custom setup? You can configure that stuff - though you probably shouldn't in case you have an application that relies on those maps. But the default configuration is CTRL+C=SIGINT and CTRL+Z=SIGTSTP.
– mikeservJun 8 '14 at 8:17

3

Caleb is right (+1). The ctrl-Z stops the program, which you should regard as "freezing" it, but that program still is in memory, it's files opened, etc. It is not killed/terminated.
– Olivier DulacJun 8 '14 at 8:23

@jiggunjer That's about the shape of things. This answer gives some background on why two steps are required and this one introduces some functions to make those steps more painless.
– CalebAug 25 '16 at 14:07