Zombie: Difference between revisions

From Hackepedia
Jump to navigationJump to search
No edit summary
m add a comma
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
A zombie [[process]] is a process awaiting collection by a parent.  To clean them up the parent [[process]] reaps the child with the [[wait]](2) [[syscall]].  [[Orphan]]ed [[process]]es are reaped by [[init]].
A zombie [[process]] is a process awaiting collection by a parent.  To clean them up the parent [[process]] reaps the child with the [[wait]](2) [[syscall]], it knows when to do this because the kernel notifies it that the child has entered zombie state by means of the SIGCHLD [[signal]].  [[Orphan]]ed [[process]]es are reaped by [[init]].
 
A zombie in the process list (ps) is indicated with flag Z, here is an example of a
user initiated zombie:
 
francisco$ ps ax|grep zombie
16912 p2  Z      0:00.00 (zombie)
16788 p2  I      0:00.01 ./zombie
27973 p2  R+      0:00.00 grep zombie (ksh)
francisco$ kill 16788
[1] + Terminated          ./zombie
 
The program is very simple it forks and the child exits immediately, the parent is in
an endless loop.  As soon as the parent is killed, init inherits the zombie child and it
waits on it making it disappear.

Latest revision as of 11:29, 31 May 2008

A zombie process is a process awaiting collection by a parent. To clean them up the parent process reaps the child with the wait(2) syscall, it knows when to do this because the kernel notifies it that the child has entered zombie state by means of the SIGCHLD signal. Orphaned processes are reaped by init.

A zombie in the process list (ps) is indicated with flag Z, here is an example of a user initiated zombie:

francisco$ ps ax|grep zombie
16912 p2  Z       0:00.00 (zombie)
16788 p2  I       0:00.01 ./zombie
27973 p2  R+      0:00.00 grep zombie (ksh)
francisco$ kill 16788
[1] + Terminated           ./zombie 

The program is very simple it forks and the child exits immediately, the parent is in an endless loop. As soon as the parent is killed, init inherits the zombie child and it waits on it making it disappear.