From owner-freebsd-stable Wed Sep 6 15:48: 9 2000 Delivered-To: freebsd-stable@freebsd.org Received: from karon.dynas.se (karon.dynas.se [192.71.43.4]) by hub.freebsd.org (Postfix) with SMTP id 50E8437B422 for ; Wed, 6 Sep 2000 15:48:02 -0700 (PDT) Received: (qmail 66313 invoked from network); 6 Sep 2000 22:48:00 -0000 Received: from spirit.sto.dynas.se (HELO spirit.dynas.se) (172.16.1.10) by karon.sto.dynas.se with SMTP; 6 Sep 2000 22:48:00 -0000 Received: (qmail 10059 invoked by uid 1125); 6 Sep 2000 22:48:04 -0000 Date: Wed, 6 Sep 2000 15:47:57 -0700 (PDT) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= X-Sender: mikko@dynas.se To: Vivek Khera Cc: Cy.Schubert@uumail.gov.bc.ca, freebsd-stable@freebsd.org Subject: Re: running lyris for linux makes many zombies In-Reply-To: <14774.47413.520585.194330@onceler.kciLink.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Reply-To: mikko@dynas.se X-MIME-Autoconverted: to 8bit by snemail 0.35 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 6 Sep 2000, Vivek Khera wrote: > >>>>> "MT" == Mikko Tyolajarvi writes: > > MT> On SYSV (and Linux) doing "signal(SIGCHLD, SIG_IGN)" is sufficient to > MT> get rid of zombies. On BSD, you have to use sigaction() with the > MT> SA_NOCLDWAIT flag to get the same result. > > MT> (Two minutes later) > > MT> Yes, the following Q&D program does not leave a zombie child on linux. > MT> But when the linux-compiled binary is run under the linuxulator, it > MT> does leave a zombie. > > MT> I.e. linuxulator bug. > > Could some kind of wrapper program be written to make children > disappear like this and then exec lyris? I suspect not since > grandchildren don't signal up to the grandparent, but I'm not that > familiar with signal handling. > > Any kind of fix would be appreciated. Right now I'm restarting the > process every 6 hours to keep zombies limited in number. Umm... you did say "any" so here we go: --- sys/i386/linux/linux_signal.c.org Wed Sep 6 14:52:15 2000 +++ sys/i386/linux/linux_signal.c Wed Sep 6 15:37:39 2000 @@ -139,6 +139,8 @@ if (linux_nsa != NULL) { nsa = stackgap_alloc(&sg, sizeof(struct sigaction)); linux_to_bsd_sigaction(linux_nsa, nsa); + if (linux_sig == LINUX_SIGCHLD && nsa->sa_handler == SIG_IGN) + nsa->sa_flags |= SA_NOCLDWAIT; } else nsa = NULL; The above patch does seem to get rid of zombies for a linux process that has done a signal(SIGCHLD, SIG_IGN). However, it has not been thorougly tested, it is likely not correct (for example, what about the return data when converting in the other direction?), it may well cause problems for all other linux programs, crash your machine, give your cat influenza, or worse. Use at your own risk (patch, build linux.ko, kldunload, kldload) NOT a certified FreeBSD kernel hacker, /Mikko Mikko Työläjärvi_______________________________________mikko@rsasecurity.com RSA Security To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message