Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Aug 2000 06:24:09 -0700
From:      "'Alfred Perlstein'" <bright@wintelcom.net>
To:        "Yevmenkin, Maksim N, CSCIO" <myevmenkin@att.com>
Cc:        core-ix@hushmail.com, freebsd-hackers@FreeBSD.ORG
Subject:   Re: Preventing zombies to occure
Message-ID:  <20000825062409.O1209@fw.wintelcom.net>
In-Reply-To: <E598F159668DD311B9C700902799EAF44734E5@njb140po01.ems.att.com>; from myevmenkin@att.com on Fri, Aug 25, 2000 at 08:58:28AM -0400
References:  <E598F159668DD311B9C700902799EAF44734E5@njb140po01.ems.att.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Yevmenkin, Maksim N, CSCIO <myevmenkin@att.com> [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 - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000825062409.O1209>