Date: Tue, 12 Jun 2001 09:53:23 +0200 From: Cejka Rudolf <cejkar@dcse.fee.vutbr.cz> To: David Malone <dwmalone@maths.tcd.ie> Cc: Peter Wemm <peter@wemm.org>, Matt Dillon <dillon@earth.backplane.com>, Terry Lambert <tlambert2@mindspring.com>, hackers@FreeBSD.ORG Subject: Re: signal(SIGCHLD, SIG_IGN) patch solving SUSv2 compatibility issue Message-ID: <20010612095323.A72009@dcse.fee.vutbr.cz> In-Reply-To: <20010611115806.A53216@walton.maths.tcd.ie>; from dwmalone@maths.tcd.ie on Mon, Jun 11, 2001 at 11:58:06AM %2B0100 References: <200106101845.f5AIje014790@earth.backplane.com> <20010611002050.362CE380E@overcee.netplex.com.au> <20010611115806.A53216@walton.maths.tcd.ie>
next in thread | previous in thread | raw e-mail | index | archive | help
David Malone wrote (2001/06/11): > On Sun, Jun 10, 2001 at 05:20:50PM -0700, Peter Wemm wrote: > > I agree totally. This should have been done ages ago, I've been burned on > > it a few times, but never badly enough to go fix it. > > I've committed this - I'll let Matt do the MFC when he feels ready. Thanks for this commit, but it works exactly in the way, which I wanted to avoid. It is something like "partially submitted and not approved by me". Please, could you look once again on it? Please please please... Thanks. ;-) - Hunk #1 from commit adds PS_NOCLDWAIT when SIG_IGN is used for SIGCHLD, so if I use sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = SIG_IGN; sigaction(SIGCHLD, &sa, NULL); sigaction(SIGCHLD, NULL, &so); I get additional flag SA_NOCLDWAIT in so.sa_flags. None of tested systems (Solaris, Unixware, Irix, Linux, Aix) works in this way. - If hunk #1 is applied, I see hunk #2 (resetting SIG_IGN to SIG_DFL for SIGCHLD) as almost unnecessary, because it is just cosmetic change now and behavior in exec() is very different among various systems. - (And I have found another bug in my original patch. Three code lines and two bad bugs... :-( :-) Here are patches for current -current (... which I had to do in the first posting). These should change the behavior as is in Solaris, where flags are not added and SIGCHLD is resetted to SIG_DFL after an exec(). I'm testing these patches on my -stable production backup server running amanda and up to now without any problem. # Back out hunk #1 from applied commit --- sys/kern/kern_sig.c.orig Mon Jun 11 21:47:29 2001 +++ sys/kern/kern_sig.c Tue Jun 12 07:42:42 2001 @@ -293,8 +293,7 @@ p->p_procsig->ps_flag |= PS_NOCLDSTOP; else p->p_procsig->ps_flag &= ~PS_NOCLDSTOP; - if ((act->sa_flags & SA_NOCLDWAIT) || - ps->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN) { + if (act->sa_flags & SA_NOCLDWAIT) { /* * Paranoia: since SA_NOCLDWAIT is implemented * by reparenting the dying child to PID 1 (and # Add test for SIG_IGN to exit1() --- sys/kern/kern_exit.c.orig Mon Jun 11 21:47:35 2001 +++ sys/kern/kern_exit.c Tue Jun 12 07:41:22 2001 @@ -341,7 +341,8 @@ * flag set, notify process 1 instead (and hope it will handle * this situation). */ - if (p->p_pptr->p_procsig->ps_flag & PS_NOCLDWAIT) { + if ((p->p_pptr->p_procsig->ps_flag & PS_NOCLDWAIT) + || p->p_pptr->p_sigacts->ps_sigact[_SIG_IDX(SIGCHLD)] == SIG_IGN) { struct proc *pp = p->p_pptr; proc_reparent(p, initproc); /* # And this is patch for question from my first posting: ... Why? I know # that sa_handler and sa_sigaction are the same pointer in an union, # but I think that "act->sa_handler" should be exchanged with # "(__sighandler_t *)act->sa_sigaction" for clarification purposes. --- sys/kern/kern_sig.c Tue Jun 12 07:42:42 2001 +++ sys/kern/kern_sig.c.new Tue Jun 12 08:16:12 2001 @@ -259,11 +259,11 @@ ps->ps_catchmask[_SIG_IDX(sig)] = act->sa_mask; SIG_CANTMASK(ps->ps_catchmask[_SIG_IDX(sig)]); if (act->sa_flags & SA_SIGINFO) { - ps->ps_sigact[_SIG_IDX(sig)] = act->sa_handler; - SIGADDSET(ps->ps_siginfo, sig); - } else { ps->ps_sigact[_SIG_IDX(sig)] = (__sighandler_t *)act->sa_sigaction; + SIGADDSET(ps->ps_siginfo, sig); + } else { + ps->ps_sigact[_SIG_IDX(sig)] = act->sa_handler; SIGDELSET(ps->ps_siginfo, sig); } if (!(act->sa_flags & SA_RESTART)) Thanks. -- Rudolf Cejka (cejkar@dcse.fee.vutbr.cz; http://www.fee.vutbr.cz/~cejkar) Brno University of Technology, Faculty of El. Engineering and Comp. Science Bozetechova 2, 612 66 Brno, Czech Republic 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?20010612095323.A72009>