exit1(): Ensure that SIGCHLD from reparented child is queued to reaper

We have a reaper R and child A with grandchild B. Now, suppose that B
already have exited, and that A did not waited on B. When A is exiting,
its child B is reparented to R, but its p_ksi was already queued for A.
This means that SIGCHLD is not queued to R, it is only marked as pending
in bitmap.

If other SIGCHLD is queued, we would miss a delivery of the notification
for B exiting.  Additionally, R does not see siginfo for B.

Do not even try to send SIGCHLD if the target is zombie.  Only update
the ksi state for possible consumption by the reaper.

Tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50752
This commit is contained in:
Konstantin Belousov
2025-06-08 10:31:28 +03:00
parent 2be717b45a
commit 8dda34d0ef
+8 -1
View File
@@ -3732,7 +3732,14 @@ sigparent(struct proc *p, int reason, int status)
if (KSI_ONQ(p->p_ksi))
return;
}
pksignal(p->p_pptr, SIGCHLD, p->p_ksi);
/*
* Do not consume p_ksi if parent is zombie, since signal is
* dropped immediately. Instead, keep it since it might be
* useful for reaper.
*/
if (p->p_pptr->p_state != PRS_ZOMBIE)
pksignal(p->p_pptr, SIGCHLD, p->p_ksi);
}
static void