kill -9
will send SIGKILL
signal to parent process. But SIGKILL
can not be caught. So How do parent process terminate child processes?
The parent, once killed via SIGKILL, will just stop existing and thus cannot send signals to its child processes any more. The child process would have to monitor its parent process by itself. When the parent gets killed, the PPID changes to 1 - this might be a helpful to the client to act on its parent being killed. But to "ensure that child process will always be closed with parent process" is not possible from the parents process - that's the nature of SIGKILL. However, if you feel brave you can always hack the source and redefine SIGKILL to something else, but I wouldn't recommend it :)