Revert the knote_processexit() bits of the diff. It introduced a small
authorclaudio <claudio@openbsd.org>
Tue, 6 Aug 2024 18:41:20 +0000 (18:41 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 6 Aug 2024 18:41:20 +0000 (18:41 +0000)
window where a knote is available but PS_ZOMBIE is not yet set (causing
waitpid() to not return that pid).
Requested by jca@ and deraadt@

sys/kern/kern_exit.c

index db989e2..280af8c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kern_exit.c,v 1.229 2024/08/06 08:44:54 claudio Exp $ */
+/*     $OpenBSD: kern_exit.c,v 1.230 2024/08/06 18:41:20 claudio Exp $ */
 /*     $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $  */
 
 /*
@@ -477,13 +477,16 @@ reaper(void *arg)
                        /* Release the rest of the process's vmspace */
                        uvm_exit(pr);
 
-                       /* Notify listeners of our demise and clean up. */
-                       knote_processexit(pr);
-
                        KERNEL_LOCK();
                        if ((pr->ps_flags & PS_NOZOMBIE) == 0) {
                                /* Process is now a true zombie. */
                                atomic_setbits_int(&pr->ps_flags, PS_ZOMBIE);
+                       }
+
+                       /* Notify listeners of our demise and clean up. */
+                       knote_processexit(pr);
+
+                       if (pr->ps_flags & PS_ZOMBIE) {
                                /* Post SIGCHLD and wake up parent. */
                                prsignal(pr->ps_pptr, SIGCHLD);
                                wakeup(pr->ps_pptr);