Kill a Zombie!

A is called a if the process has been completed, but its PID and process entry remains in the Linux process table. A process is removed from the process table when the process is completed, and its reads the completed process' status by using the () . If a parent process fails to call wait() for whatever reason, its will be left in the process table, becoming a zombie.

To find zombie processes on Linux:

$ axo stat,ppid,pid,comm | grep -w defunct Z 250 10242 fake-prog

The above command searches for processes with zombie (defunct) state, and displays them in (state, PPID, PID, command-name) format. The sample output shows that there is one zombie process associated with "fake-prog", and it was spawned by a parent process with PID 250.

Killing zombie processes is not obvious since zombie processes are already dead. You can try two options to a zombie process on Linux as follows.

First, you can try sending SIGCHLD to the zombie's parent process using the kill command. Note that the above command gives you PPID (PID of parent process) of each zombie. In our example, PPID of the zombie is 250.

$ sudo kill -s SIGCHLD 250

If a zombie process still does not go away, you can kill the parent process (e.g., 250) of the zombie.

$ sudo kill -9 250

Once its parent process gets killed, the zombie will be adopted by the process, which is a parent of all processes in Linux. The init process periodically calls wait() to reap any zombie process.