The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=8dda34d0ef79d0d247b3487ae0499bdf12c9209e

commit 8dda34d0ef79d0d247b3487ae0499bdf12c9209e
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2025-06-08 07:31:28 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2025-06-09 23:50:57 +0000

    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
---
 sys/kern/kern_sig.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 3df4e8f0fb25..c972d0620ab2 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -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

Reply via email to