Remove a process from the zombie list before starting to destruct its data structures.
authorSimon 'corecode' Schubert <corecode@fs.ei.tum.de>
Sun, 28 Dec 2008 13:24:07 +0000 (14:24 +0100)
committerSimon 'corecode' Schubert <corecode@fs.ei.tum.de>
Mon, 29 Dec 2008 18:43:49 +0000 (19:43 +0100)
sys/kern/kern_exit.c

index 8ef3f0e..0fd4380 100644 (file)
@@ -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;