Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Sep 2000 15:47:57 -0700 (PDT)
From:      =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mikko@dynas.se>
To:        Vivek Khera <khera@kciLink.com>
Cc:        Cy.Schubert@uumail.gov.bc.ca, freebsd-stable@freebsd.org
Subject:   Re: running lyris for linux makes many zombies 
Message-ID:  <Pine.BSF.4.21.0009061541120.271-100000@explorer.rsa.com>
In-Reply-To: <14774.47413.520585.194330@onceler.kciLink.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 6 Sep 2000, Vivek Khera wrote:

> >>>>> "MT" == Mikko Tyolajarvi <mikko@dynas.se> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0009061541120.271-100000>