> -----Original Message-----
> From: John Brooking [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, April 28, 2002 8:43 PM
> To: Connie Chan
> Cc: [EMAIL PROTECTED]
> Subject: Re: Multi thread ? Programming Style ? [with update]
> 
> ...
>   A "zombie" process is one that has been started, but
> for one reason or another, can't finish, so it's just
> hung there. I'm not a Unix sysadm, and haven't been a
> user for quite a while, so I'm a little fuzzy at this
> point on exactly what could cause this to happen.

A zombie process is a process that has exited, but whose
parent has not yet called wait(2) to reap the process'
exit status. The process itself has finished and its
resources have been released, so it's not "hung". The
only thing left is a slot in the kernel's process table.

This may be because:

a) the parent is busy doing something, and will get 
around to calling wait(2) at some point, or

b) the parent doesn't care about the exit status, and 
hasn't been coded properly to either reap or ignore 
the exit status.

In case (a), you don't need to do anything. The zombie
will go away when wait(2) is called.

In case (b), you either need to terminate the parent
or code it to ignore SIGCHLD (or call wait(2)).

In the case of a CGI script forking a long-running
child, the parent (the CGI script) exits before the child.
In this case, the child is "inherited" by PID 1 (init),
which will reap the process when it terminates, so
you don't have to do anything special.

Exception: if the script is running under mod_perl or
some other long-running process, case (b) above may
apply and you may have zombies hanging around until
the web server process is terminated. To avoid this,
you should ignore SIGCHLD in the parent process:

   $SIG{CHLD} = 'IGNORE';


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to