diff options
author | Ian Moffett <ian@osmora.org> | 2025-07-17 00:22:23 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-07-17 00:31:09 -0400 |
commit | a802482670de836e7b255805f6d05cd908992a34 (patch) | |
tree | ae7852434cf5adf0492e49ff1af05dfdf48a8cf4 /sys | |
parent | 03be1cab4f04dc8b825a226913b385843beba596 (diff) |
kernel: exit: Reassign children to init on exit
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_exit.c | 7 |
1 files changed, 4 insertions, 3 deletions
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; } } |