git: procctl(2): Improve PROC_REAP_KILL to handle reparenting race

Aaron LI aly at crater.dragonflybsd.org
Tue Mar 18 18:06:45 PDT 2025


commit cabad5ba2c6d83815f67fbf3ecb1e41f03a265a3
Author: Aaron LI <aly at aaronly.me>
Date:   Mon Mar 17 13:36:58 2025 +0800

    procctl(2): Improve PROC_REAP_KILL to handle reparenting race
    
    During the process tree iteration, a process or a process subtree might
    be reparented (because of SIGTERM/SIGKILL or ptrace/debug).  In order to
    handle that race, we reset the p_reaptid to 0 whenever a process gets
    reparented, and then check the p_reaptid value during the iteration.  If
    a reparent is detected, we restart the iteration.
    
    Suggested-by: dillon
    Reviewed-by: dillon

Summary of changes:
 sys/kern/kern_exit.c | 2 ++
 sys/kern/kern_fork.c | 9 +++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/cabad5ba2c6d83815f67fbf3ecb1e41f03a265a3


-- 
DragonFly BSD source repository


More information about the Commits mailing list