Zombie processes

While checking the process list, you might have noticed something like this : sh <defunct>

These are zombie processes. On Unix operating systems, a zombie process or defunct process is a process that has completed execution but still has an entry in the process table, allowing the process that started it to read its exit status. It almost always means that the parent is still around. If the parent exited, the child would be orphaned and re-parented to init, which would immediately perform the wait(). In other words, they should go away once the parent process is done.

A zombie process doesn’t react to signals.

You can see a count of your zombie processes using the following script:

ps aux | awk '{ print $8 " " $2 }' | grep -w Z 

In order to kill these processes, you need to find the parent process first.

pstree -paul 

This will show the pid of the of the parent of the zombie process. Now you need to kill the parent process.

kill -9 <pid>

That’s it!