From owner-freebsd-hackers Fri Aug 25 6:24:44 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 40D2337B43C for ; Fri, 25 Aug 2000 06:24:42 -0700 (PDT) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id e7PDO9t16755; Fri, 25 Aug 2000 06:24:09 -0700 (PDT) Date: Fri, 25 Aug 2000 06:24:09 -0700 From: "'Alfred Perlstein'" To: "Yevmenkin, Maksim N, CSCIO" Cc: core-ix@hushmail.com, freebsd-hackers@FreeBSD.ORG Subject: Re: Preventing zombies to occure Message-ID: <20000825062409.O1209@fw.wintelcom.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i In-Reply-To: ; from myevmenkin@att.com on Fri, Aug 25, 2000 at 08:58:28AM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Yevmenkin, Maksim N, CSCIO [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