From owner-freebsd-hackers Sun Jul 22 11:49:30 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 4344237B405 for ; Sun, 22 Jul 2001 11:49:25 -0700 (PDT) (envelope-from dillon@earth.backplane.com) Received: (from dillon@localhost) by earth.backplane.com (8.11.4/8.11.2) id f6MIn4x10989; Sun, 22 Jul 2001 11:49:04 -0700 (PDT) (envelope-from dillon) Date: Sun, 22 Jul 2001 11:49:04 -0700 (PDT) From: Matt Dillon Message-Id: <200107221849.f6MIn4x10989@earth.backplane.com> To: Cejka Rudolf Cc: David Malone , Peter Wemm , Terry Lambert , hackers@FreeBSD.ORG Subject: Re: signal(SIGCHLD, SIG_IGN) patch solving SUSv2 compatibility issue References: <200106101845.f5AIje014790@earth.backplane.com> <20010611002050.362CE380E@overcee.netplex.com.au> <20010611115806.A53216@walton.maths.tcd.ie> <20010612095323.A72009@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 :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. ;-) Ok, sorry for the long delay, I've been playing catchup. I've committed these additional changes to -current and I will MFC the combined signal patch to -stable in 3 days. It looks really solid to me. This should satisfy everyone. -Matt :- 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