Monday, May 23, 2011

Zombie Process Understanding.

A zombie 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.

When a process ends, all of the memory and resources associated with it are deallocated so they can be used by other processes.

However, the process's entry in the process table remains. The parent is sent a SIGCHLD signal indicating that a child has died; the handler for this signal will typically execute the wait system call, which reads the exit status and removes the zombie.

The zombie's process ID and entry in the process table can then be reused. However, if a parent ignores the SIGCHLD, the zombie will be left in the process table.

In some situations this may be desirable, for example if the parent creates another child process it ensures that it will not be allocated the same process ID.


If you have zombie processes it means those zombies have not been waited for by their parent.

To remove zombies from a system, the SIGCHLD signal can be sent to the parent manually, using the kill command. If the parent process still refuses to reap the zombie, the next step would be to remove the parent process. When a process loses its parent, init becomes its new parent. Init periodically executes the wait system call to reap any zombies with init as parent.


How to find "zombie" process in Linux ?

Execute "top" command & read top left corner to check zombie process. If you are unable to identify the process, press "z" & you will get "red" colored identification for easy understanding.

How to kill "zombie" process in Linux ?

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


Output would be,
Z 3456
Z 2107
Z 1708
Use "Kill command" for all three processes as given below.

kill -9 3456
kill -9 2107
kill -9 1708

That's it. Enjoy Linux.


No comments:

Post a Comment