How to kill zombie processes & What is zombie process?

I would like to explore linux zombie process in this blog ..

Zombie processes are also called “defunct” processes in the system. Those are processes whose execution is completed, but the parent is not aware of it or parent didnt reap its child, so it holds entry in process table. It will not waste any other resources in the system. The only resource it wastes is this entry in the table. It becomes an issue only when we/system reaches the situation: “The total no of processes running in the system is equal to the max limit of number of processes”. Then we may worry about them. The main chance for zombie creation is when a parent didnt wait() for this child, in other words crappy application developers can generate a zombie process 🙂

How can we kill zombie processes?

It is said that we can send SIGKILL to kill zombie processes . This is NOT correct. How-ever you can try the methods mentioned below to get rid of this.

1) Reboot the system

2) Try to send “SIGCHLD” signal to the parent process. This may work , if parent honours this signal

3) Change the application/parent to include wait() family of system calls, so there wont be any more zombie process from that application as this will cause proper reaping of child process.

4) You can try to kill parent process.

5) As a last option you may play with debuggers to get rid of it.

Now, for fun I tried to create a zombie process in my system ..

[root@humbles-lap ~]# cat zombie.c

Lets compile and run it ..

When above program is running.. In another terminal:

Rest of the stuffs are homework…

Leave a Reply

Your email address will not be published. Required fields are marked *