views:

1265

answers:

3

One of my colleague told me this morning, when he killed supervisord by "kill -9", the subprocesses of supervisord is not killed.

He is quite sure about that, but I tried many times and did not find that happen.

So when a parent process is killed by "kill -9", will linux ensure that it's sub-processes also been killed?

+3  A: 

No, child processes are not necessarily killed when the parent is killed.

However, if the child has a pipe open which it is writing to and the parent is reading from, it will get a SIGPIPE when it next tries to write to the pipe, for which the default action is to kill it. That is often what happens in practice.

caf
+2  A: 

You have to make the sub processes daemonic in order to have them killed when the father is killed (or dies), otherwise they are adopted by init(1).

AlberT
Here is a link to how to create a zombie process if you are interested in how they are created and to experiment with how they are handled for your system:http://www.unix.com/unix-dummies-questions-answers/100737-how-do-you-create-zombie-process.html
Klathzazt
A: 

On UNIX, there is no enforced relation between parent and child process's lifetimes. Strictly speaking, process will only terminate when it calls exit() or receives unhandled signal for which default action is to terminate. However, entire "foreground process group" in a "controlling terminal" can receive SIGINT, SIGQUIT, etc. signals when user hits ctrl-C, ctrl-\, etc. on that terminal. Specific behaviour is partly implemented by login shell (with help from tty driver), details may be quite complicated: look here and here

Artur