Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Apr 2009 22:54:09 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        gavin@freebsd.org
Cc:        freebsd-bugs@freebsd.org, freebsd-standards@freebsd.org, Jilles Tjoelker <jilles@stack.nl>, alan@pair.com
Subject:   Re: bin/108390: [libc] [patch] wait4() erroneously waits for all children when SIGCHLD is SIG_IGN [regression]
Message-ID:  <20090419195409.GY3014@deviant.kiev.zoral.com.ua>
In-Reply-To: <200904161242.n3GCgG4u063936@freefall.freebsd.org>
References:  <200904161242.n3GCgG4u063936@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--6ISAYjCz29ajFyjn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.

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);
=20

--6ISAYjCz29ajFyjn
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)

iEYEARECAAYFAknrgWAACgkQC3+MBN1Mb4hWuACg3+YKH57zkiMYI0esiPnemGKd
NaAAnRS3H0JR8hkKS4DWPjAFkoUgTt0M
=8+CH
-----END PGP SIGNATURE-----

--6ISAYjCz29ajFyjn--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090419195409.GY3014>