git: 1575804961d2 - main - reap_kill_proc(): avoid singlethreading any other process if we are exiting

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 13 Jun 2022 19:33:43 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=1575804961d2ba1768c9a6b28438d364421718f3

commit 1575804961d2ba1768c9a6b28438d364421718f3
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-05-16 23:47:20 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-06-13 19:30:03 +0000

    reap_kill_proc(): avoid singlethreading any other process if we are exiting
    
    This is racy because curproc process lock is not used, but allows the
    process to exit faster.  It is userspace issue to create such race
    anyway, and not fullfilling the guarantee that all reaper descendants
    are signalled should be fine.
    
    In collaboration with:  pho
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Differential revision:  https://reviews.freebsd.org/D35310
---
 sys/kern/kern_procctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c
index b32a4156dafb..79725686bc44 100644
--- a/sys/kern/kern_procctl.c
+++ b/sys/kern/kern_procctl.c
@@ -291,6 +291,7 @@ reap_kill_proc_locked(struct thread *td, struct proc *p2,
 	 * race.
 	 */
 	need_stop = p2 != td->td_proc &&
+	    (td->td_proc->p_flag2 & P2_WEXIT) == 0 &&
 	    (p2->p_flag & (P_KPROC | P_SYSTEM | P_STOPPED)) == 0 &&
 	    (rk->rk_flags & REAPER_KILL_CHILDREN) == 0;