From 3c8687d6a8886aa7b659151a2ac4fde24931fbfb Mon Sep 17 00:00:00 2001 From: Simon 'corecode' Schubert Date: Sun, 28 Dec 2008 14:24:07 +0100 Subject: [PATCH] Remove a process from the zombie list before starting to destruct its data structures. --- sys/kern/kern_exit.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 8ef3f0e870..0fd4380cd1 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -800,6 +800,17 @@ loop: wakeup((caddr_t)t); return (0); } + + /* + * Unlink the proc from its process group so that + * the following operations won't lead to an + * inconsistent state for processes running down + * the zombie list. + */ + KKASSERT(p->p_lock == 0); + proc_remove_zombie(p); + leavepgrp(p); + p->p_xstat = 0; ruadd(&q->p_cru, &p->p_ru); @@ -820,14 +831,6 @@ loop: if (p->p_args && --p->p_args->ar_ref == 0) FREE(p->p_args, M_PARGS); - /* - * Finally finished with old proc entry. - * Unlink it from its process group and free it. - */ - KKASSERT(p->p_lock == 0); - proc_remove_zombie(p); - leavepgrp(p); - if (--p->p_sigacts->ps_refcnt == 0) { kfree(p->p_sigacts, M_SUBPROC); p->p_sigacts = NULL; -- 2.41.0