====== man top ====== [root /var/www/html 06:08:47] # man top w: S -- Process Status The status of the task which can be one of: D = uninterruptible sleep R = running S = sleeping T = traced or stopped Z = zombie ====== man wait ====== "A child that terminates, but has not been waited for becomes a 'zombie.' The kernel maintains a minimal set of information about the zombie process (PID, termination status, resource usage information) in order to allow the parent to later perform a wait to obtain information about the child."[[http://linux.die.net/man/2/wait|man wait(2)]] ====== rack.org ====== [[http://www.rack.org/sysadmin/ascii/02.01/weinstei/weinstei.txt]]: "Zombies are nothing harmful, just a sign that the parent process has yet to collect the status of its sub-processes that have exited. Causing the parents to wake up and reap their children will cause the zombies to go away." ====== Orphaned zombies are bad ====== ===== Zombies could fill up process tables ===== [[http://www.samgeneration.com/Book/perl4/cook/ch16_20.htm|O'Reilly Perl Cookbook]]: 16.19. Avoiding Zombie Processes 16.19.1. Problem Your program forks children, but the dead children accumulate, fill up your process table, and aggravate your system administrator. //But we don't have orphaned zombies on our system. They are not filling up the process table. They come and go in an orderly fashion.// ===== No orphan zombies here, boss ===== ''ps aux | awk '{ print $8 " " $2 }' | grep -w Z'' [23:21:53] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z Z 29838 Z 29853 Z 29854 **Three zombies found at 23:21:53.** [23:32:42] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z Z 29956 Z 29958 Z 29959 **Three entirely different zombies eleven minutes later.** [23:32:50] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z **0 zobmies 8 seconds later.** [23:32:55] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z Z 30073 **1 zombie 5 seconds later.** [23:32:59] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z Z 30117 Z 30118 **2 zombies 4 seconds later.** [23:33:02] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z **0 zombies 3 seconds later.** [23:33:05] # ps aux | awk '{ print $8 " " $2 }' | grep -w Z Z 30161 **1 zombie 3 seconds later.** None of the zombies are orphans. They only stay on the list until the result code is checked, then they vanish. The process ids increase from 29838 to 30161 over the course of the experiment. // "... in all my years dealing with UNIX and Linux systems, I've never seen anything that spawns threads and leaves them behind like that." // They are not "left behind." A zombie is not necessarily an orphan. Some zombies are left in Dead Care while their parents are busy; when the parents come back, the dead babies get reaped and disappear forever. The zombies in Dead Care are quiet and well-behaved. When they have fulfilled their mission by providing the result code from the process, they go away in peace. They do not hang around like the orphaned zombies whose results are unwanted and whose presence is meaningless. ===== Wait for your children ===== "Under UNIX, a process does not really exit. Instead, it returns to its parent. Typically, a parent process waits for its child process, and obtains a return value. However, our daemon process cannot simply stop and wait. That would defeat the whole purpose of creating additional processes. But if it never does wait, its children will become zombies--no longer functional but still roaming around. "For that reason, the daemon process needs to set signal handlers in its initialize daemon phase. At least a SIGCHLD signal has to be processed, so the daemon can remove the zombie return values from the system and release the system resources they are taking up."[[http://www.freebsd.org/doc/en/books/developers-handbook/book.html#SOCKETS-CONCURRENT-SERVERS|Free BSD Developers' Handbook]] //This text is using a non-standard definition of 'zombie.' It is conflating 'zombie' and 'orphan.' The two concepts are not identical as shown below.// ====== John Shapely Gray ====== * Source: [[http://books.google.com/books?id=pF2ka_E_R5YC&pg=PA107&lpg=PA107&dq=%22process+status%22+zombie&source=bl&ots=llpdbYahn0&sig=h6hnwO1lppi31xcdmq0gp0TDdCU&hl=en&ei=7NbmSrWHH43AlAfimrGCCA&sa=X&oi=book_result&ct=result&resnum=10&ved=0CCkQ6AEwCQ#v=onepage&q=%22process%20status%22%20zombie&f=false|books.google.com--Interprocess communications in Linux]] {{:blog:z1.png|}} ====== Robert M. Dondero, Jr. ====== * Source: [[http://www.cs.princeton.edu/courses/archive/spring08/cos217/precepthandouts/23/orphanzombie.pdf|orphanzombie.pdf]] {{:blog:z2.png|}} === Five paths; four happy outcomes. === - Parent and child exit together. - Normal Zombie: the child waits until the parent retrieves the return code, then exits gracefully. - Orphan Zombie converted to a Normal Zombie: Process 0 adopts the child, giving it a parent; then, acting as a good parent should, process 0 acts as if it cares, looks at the return result, and lets the newly normalized Zombie go in peace. - Orphan converted to a Normal Zombie: the parent runs away from the child, turning the child into an orphan; when the child exits, it goes onto the Zombie list. Process 0 adopts the child, giving it a parent; then, acting as a good parent should, process 0 acts as if it cares, looks at the return result, and lets the nely normalized Zombie go in peace. (So, actually, the arrow from the diagram should run over to the "Orphan Zombie" box in path #3. Once the Orphan gets turned into an "Orphan Zombie," the procedure is identical to the third path). - An abandoned child (i.e., Orphan) that never exits is trouble. Because it never exits, it never gets turned into a an adopted Orphan Zombie, never returns a result, and never lets go of its resources. === A new and improved flow chart === {{:blog:zombie.png|}} ====== Kay A. Robbins ====== * Source: [[http://books.google.com/books?id=tdsZHyH9bQEC&pg=PA51&lpg=PA51&dq=%22process+status%22+zombie&source=bl&ots=rs_i9-j-ib&sig=sxz_uHvNwdrd-rs69h4tRWntO9I&hl=en&ei=v9vmSpqvDNKvlAf4i7D6Bw&sa=X&oi=book_result&ct=result&resnum=1&ved=0CAwQ6AEwADg8#v=onepage&q=%22process%20status%22%20zombie&f=false|books.google.com--UNIX systems programming: communication, concurrency, and threads]] {{:blog:z3.png|}} ====== Rosen, Host, Klee, and Rosinski ====== * Source: [[http://books.google.com/books?id=2Et--84HIkwC&pg=RA1-PA306&lpg=RA1-PA306&dq=%22process+status%22+zombie&source=bl&ots=ISj8wAmUPW&sig=ERQtCTWV7T8MpHTGDK_dUXvao7o&hl=en&ei=v9vmSpqvDNKvlAf4i7D6Bw&sa=X&oi=book_result&ct=result&resnum=8&ved=0CCQQ6AEwBzg8#v=onepage&q=zombie&f=false|books.google.com--Unix: The Complete Reference]] {{:blog:z4.png|}} //Copying the main lines from the capture:// "When a process issues the exit call, the kernel disables all signal handling associated with the process, and converts the process into the //zombie state//. A process in the //zombie state// is not alive; it does not use any resources or accomplish any work. But it is not allowed to die until the exit is acknowledged by the parent process. "If the parent does not acknowledge the death of the child (because the parent is ignoring the signal, or because the parent itself is hung), the child stays around as a //zombie process//. ... "Because a zombie process consumes no CPU time and is attached to no terminal, the STIME and TTY fields are blank. In earlier versions of the UNIX System, the number of these zombie processes could increase and clutter up the process table. In more recent versions of the UNIX System, the kernel automatically releases the zombie processes." ====== Podcast: Living with the Undead ====== [[http://screencast.com/t/OovvnqbP|Demonstration of how zombies come and go on our system.]]