From f2312b4af97185a266d1a145b90f36b4cdfb57b3 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 24 Jun 2025 02:33:11 -0400 Subject: kernel: exit: Only kill leaf if not exiting During an exit(), the parent needs to kill all of the child processes that depend on it. However, there might be an occurrence where one or more is already exiting and trying to kill such processes would be problematic and may result in issues like double frees. This commit ensures that the exiting parent only kills child processes that aren't already exiting themselves. Signed-off-by: Ian Moffett --- sys/kern/kern_exit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 2f9e344..c00f39b 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -129,7 +129,8 @@ exit1(struct proc *td, int flags) /* If we have any children, kill them too */ if (td->nleaves > 0) { TAILQ_FOREACH(procp, &td->leafq, leaf_link) { - exit1(procp, flags); + if (!ISSET(procp->flags, PROC_EXITING)) + exit1(procp, flags); } } -- cgit v1.2.3