From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 20 15:47:00 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 DE86E1065678; Mon, 20 Apr 2009 15:47:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 7D56E8FC0A; Mon, 20 Apr 2009 15:47:00 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1Lvvhx-0006pI-PG; Mon, 20 Apr 2009 18:46:57 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n3KFktQd076761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 20 Apr 2009 18:46:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n3KFksXe051649; Mon, 20 Apr 2009 18:46:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n3KFks3x051648; Mon, 20 Apr 2009 18:46:54 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 20 Apr 2009 18:46:54 +0300 From: Kostik Belousov To: Alan Ferrency Message-ID: <20090420154654.GC3014@deviant.kiev.zoral.com.ua> References: <200904161242.n3GCgG4u063936@freefall.freebsd.org> <20090419195409.GY3014@deviant.kiev.zoral.com.ua> <20090420112723.S1321@smx2.pair.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wg2zgDM1gLxA7pbN" Content-Disposition: inline In-Reply-To: <20090420112723.S1321@smx2.pair.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1Lvvhx-0006pI-PG deac457fd46d3abe60b1157bc7b16345 X-Terabit: YES 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 15:47:01 -0000 --wg2zgDM1gLxA7pbN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 20, 2009 at 11:40:08AM -0400, Alan Ferrency wrote: > >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. >=20 > If I'm interpreting Jilles' notes about this proposed patch, it seems > like this would solve our primary problem. >=20 > 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. Yes, this is what happens after the patch. I committed the change today. >=20 > 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. >=20 > Thanks for the patch,=20 > Alan Ferrency > pair Networks, Inc. >=20 > >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 =3D 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); > > > > --wg2zgDM1gLxA7pbN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAknsmO4ACgkQC3+MBN1Mb4iWdQCdH+w7GKVa9G4FR1g6/bKVxLmL KHUAoOHOecTUsu29Bu1xronT9WZKgjXm =Ovvv -----END PGP SIGNATURE----- --wg2zgDM1gLxA7pbN--