From owner-freebsd-hackers Sun Jun 10 11:46: 9 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from earth.backplane.com (earth-nat-cw.backplane.com [208.161.114.67]) by hub.freebsd.org (Postfix) with ESMTP id F287937B401 for ; Sun, 10 Jun 2001 11:45:54 -0700 (PDT) (envelope-from dillon@earth.backplane.com) Received: (from dillon@localhost) by earth.backplane.com (8.11.3/8.11.2) id f5AIje014790; Sun, 10 Jun 2001 11:45:40 -0700 (PDT) (envelope-from dillon) Date: Sun, 10 Jun 2001 11:45:40 -0700 (PDT) From: Matt Dillon Message-Id: <200106101845.f5AIje014790@earth.backplane.com> To: Cejka Rudolf Cc: David Malone , Terry Lambert , hackers@FreeBSD.ORG Subject: signal(SIGCHLD, SIG_IGN) patch solving SUSv2 compatibility issue References: <20010610183637.A73238@dcse.fee.vutbr.cz> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG :... : :sigemptyset(&sa.sa_mask); :sa.sa_flags = 0; :sa.sa_handler = SIG_IGN; :sigaction(SIGCHLD, &sa, NULL); : :zombies are still created in FreeBSD, which is against SUSv2. : :My citation was quoted directly from sigaction() page and not :from signal() page. Unfortunately, I do not have access to POSIX, :so I do not know if it is specified in SUSv2 only or if it is :specified in both SUSv2 and in POSIX. I'm afraid that it is in both. :However I think, that FreeBSD wants to be SUSv2 compliant too, or not? :... I did some research and while I couldn't find the official POSIX spec, I did read the SUSv2 spec carefully and I looked at a lot of manual pages. I believe your change is correct. We should disable zombie reaping if SIGCHLD is set to SIG_IGN. This is, in fact, how most systems do it. BSD is like the sickly child in some respects :-) Your (revised) patch, which I have reproduced below along with a little cleanup, looks correct. I compiled up a kernel with the revised patch and tested it, and it seems to work as advertised. I would say this should go into -current now. I would be happy to do this, or David Malone can since he provided the fix to the original patch. I would also recommend that we MFC the patch to -stable after a few days. It is highly unlikely to break anything. I suppose I could take the heat for that :-) Every major forking program I've ever written has had to set the sigaction flag *AND* set the signal handle to SIG_IGN to be portable, and while I probably won't stop, it would be nice to know that FreeBSD works both ways. -Matt Index: kern_sig.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_sig.c,v retrieving revision 1.72.2.6 diff -u -r1.72.2.6 kern_sig.c --- kern_sig.c 2001/05/10 17:54:16 1.72.2.6 +++ kern_sig.c 2001/06/10 18:30:42 @@ -268,7 +268,9 @@ p->p_procsig->ps_flag |= PS_NOCLDSTOP; else p->p_procsig->ps_flag &= ~PS_NOCLDSTOP; - if (act->sa_flags & SA_NOCLDWAIT) { + if ((act->sa_flags & SA_NOCLDWAIT) || + ps->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN + ) { /* * Paranoia: since SA_NOCLDWAIT is implemented * by reparenting the dying child to PID 1 (and @@ -279,8 +281,9 @@ p->p_procsig->ps_flag &= ~PS_NOCLDWAIT; else p->p_procsig->ps_flag |= PS_NOCLDWAIT; - } else + } else { p->p_procsig->ps_flag &= ~PS_NOCLDWAIT; + } } /* * Set bit in p_sigignore for signals that are set to SIG_IGN, @@ -438,6 +441,8 @@ * Reset no zombies if child dies flag as Solaris does. */ p->p_procsig->ps_flag &= ~PS_NOCLDWAIT; + if (ps->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN) + ps->ps_sigact[_SIG_IDX(SIGCHLD)] = SIG_DFL; } /* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message