From a802482670de836e7b255805f6d05cd908992a34 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 17 Jul 2025 00:22:23 -0400 Subject: kernel: exit: Reassign children to init on exit Signed-off-by: Ian Moffett --- sys/kern/kern_exit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 6b41cbd..9377eed 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -46,6 +46,7 @@ #define pr_error(...) pr_trace(__VA_ARGS__) extern volatile size_t g_nthreads; +extern struct proc g_init; static void unload_td(struct proc *td) @@ -150,17 +151,17 @@ exit1(struct proc *td, int flags) curtd = this_td(); curpid = curtd->pid; + td->flags |= PROC_EXITING; parent = td->parent; /* We have one less process in the system! */ atomic_dec_64(&g_nthreads); - /* If we have any children, kill them too */ + /* Reassign children to init */ if (td->nleaves > 0) { TAILQ_FOREACH(procp, &td->leafq, leaf_link) { - if (!ISSET(procp->flags, PROC_EXITING)) - exit1(procp, flags); + procp->parent = &g_init; } } -- cgit v1.2.3