From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 20 16:06:50 2009 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 68DF7106566B for ; Mon, 20 Apr 2009 16:06:50 +0000 (UTC) (envelope-from alan@pair.com) Received: from smx2.pair.com (smx2.pair.com [66.39.3.19]) by mx1.freebsd.org (Postfix) with SMTP id 264088FC13 for ; Mon, 20 Apr 2009 16:06:50 +0000 (UTC) (envelope-from alan@pair.com) Received: (qmail 51118 invoked by uid 1037); 20 Apr 2009 15:40:08 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 20 Apr 2009 15:40:08 -0000 Date: Mon, 20 Apr 2009 11:40:08 -0400 (EDT) From: Alan Ferrency To: Kostik Belousov In-Reply-To: <20090419195409.GY3014@deviant.kiev.zoral.com.ua> Message-ID: <20090420112723.S1321@smx2.pair.com> References: <200904161242.n3GCgG4u063936@freefall.freebsd.org> <20090419195409.GY3014@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-bugs@freebsd.org, gavin@freebsd.org, freebsd-standards@freebsd.org, Jilles Tjoelker Subject: Re: bin/108390: [libc] [patch] wait4() erroneously waits for all children when SIGCHLD is SIG_IGN [regression] X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2009 16:06:50 -0000 > Further check on Solaris revealed that for the case where SIGCHLD is > ignored, wait4() returned -1/ECHLD, conforming to the FreeBSD behaviour > of reparenting to init. If I'm interpreting Jilles' notes about this proposed patch, it seems like this would solve our primary problem. That is: we already receive a -1/ECHLD when we call wait4pid() as expected, but we don't receive it in a timely manner if there are other child processes still running. If this patch causes wait4pid() to return immediately when a nonexistent (exited) child PID is specified, that would meet our expectations and preferences. Regarding SA_NOCLDWAIT: it was previously my understanding that SA_NOCLDWAIT and igoring SIGCHLD affect two different aspects of child process management. On a previous occasion when I looked into the behavior of SA_NOCLDWAIT, it wasn't even implemented on Linux yet; but obviously, ignoring SIGCHLD was supported. Thanks for the patch, Alan Ferrency pair Networks, Inc. > Unless further comments are given, I will commit this in several days: > > diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c > index 4255734..c35c6f2 100644 > --- a/sys/kern/kern_exit.c > +++ b/sys/kern/kern_exit.c > @@ -504,13 +504,13 @@ exit1(struct thread *td, int rv) > proc_reparent(p, initproc); > p->p_sigparent = SIGCHLD; > PROC_LOCK(p->p_pptr); > + > /* > - * If this was the last child of our parent, notify > - * parent, so in case he was wait(2)ing, he will > + * Notify parent, so in case he was wait(2)ing or > + * executiing waitpid(2) with our pid, he will > * continue. > */ > - if (LIST_EMPTY(&pp->p_children)) > - wakeup(pp); > + wakeup(pp); > } else > mtx_unlock(&p->p_pptr->p_sigacts->ps_mtx); > >