When parent process is sent SIGTERM signal, the parent process will execute it's own signal handlers to terminate it's child processes.
In the below case, sending SIGTERM to parent process ID 2086, kills all the child process too
# ps -eHf | grep http
root 2086 1 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2088 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2089 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2090 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2091 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2092 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2093 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2094 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
apache 2095 2086 0 07:11 ? 00:00:00 /usr/sbin/httpd
# kill 2086
# ps -eHf | grep http
root 2128 1932 0 07:12 pts/0 00:00:00 grep http
However, sending the parent process -9 signal (SIGKILL), will not allow to execute it's signal handlers. So parent process will not be able to send termination signal to it's child processes. So only parent process will get killed and child processes will live.
root 2157 1932 0 07:12 pts/0 00:00:00 grep http
root 2144 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2146 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2147 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2148 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2149 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2150 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2151 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2152 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2153 2144 0 07:12 ? 00:00:00 /usr/sbin/httpd
# kill -9 2144
# ps -eHf | grep http
root 2190 1932 0 07:13 pts/0 00:00:00 grep http
apache 2146 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2147 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2148 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2149 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2150 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2151 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2152 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
apache 2153 1 0 07:12 ? 00:00:00 /usr/sbin/httpd
No comments:
Post a Comment