2

I have a question. Studying processes management I observed a strange behavior, on a CentOS 7. I know that killing a parent process, the child processes are killed also. But not in the following case. I ran the command dd, just for example:

[root@server2 ~]# dd if=/dev/zero of=/dev/null &
[1] 1756

[root@server2 ~]# ps fax | grep -B2 dd
1737 pts/2    S      0:00         \_ su -
1741 pts/2    S      0:00             \_ -bash
1756 pts/2    R      1:18                 \_ dd if=/dev/zero of=/dev/null

After that I tried to kill (with SIGKILL signal) the parent process, that is the bash, but this action doesn't kill the dd process:

[root@server2 ~]# kill -9 1741
Killed
[user@server2 ~]#

The shell terminates but as you can see in the top command output, the dd process is still working:

PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                           
1756 root      20   0  107948    612    512 R 99.9  0.1  10:06.98 dd      

Do you have any idea about it please?

5

By default killing a parent process does not kill the children processes.

I suggest you look for other questions about how to kill both the parent and child using the process group (a negative PID).

A good answer about how to do this in detail can be found at Process descendants

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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