* Yevmenkin, Maksim N, CSCIO <[EMAIL PROTECTED]> [000825 05:59] wrote:
> > 
> > [snip]
> > 
> > If a parent that has zombie children exits the kernel will attach them
> > to init (I haven't checked, but this is the common unix solution).  
> > init will be calling waitpid to clear zombies automagically.
> > 
> > So this sorta already happens. :)
> 
> two ways:
> 
> first:
> 
> something like
> 
> SIGCHLD_handler(int)
> {
>       while (waitpid(-1, NULL, 0))
>               ;
> }

This could be wrong if:

     [EINTR]            The call was interrupted by a caught signal, or the
                        signal did not have the SA_RESTART flag set.

more proper (paraniod) would be:

int
sigchld_handler(int) 
{

        while (waitpid(-1, NULL, 0) || errno == EINTR)
                ;
}

> you need to handle SIGCHLD, otherwise you will have zombies.
> 
> second:
> 
> use SA_NOCLDWAID flag in sigaction(2) 
> in this case ``init'' will be responsible for zombie process

typo: should be 'SA_NOCLDWAIT'.

Sorry to pick, but one must be careful.

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to