summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2000-12-01 03:42:17 +0000
committerjhb <jhb@FreeBSD.org>2000-12-01 03:42:17 +0000
commit83d14553fcd8bd25049ae5b34b34acc66963e1a0 (patch)
tree7e543c5c5c7e39c3628fbc9bad0f323e70605fe5 /sys/kern/kern_exit.c
parent03d643bc436bb035b6b35d62f06cd02f0f76cfd1 (diff)
downloadFreeBSD-src-83d14553fcd8bd25049ae5b34b34acc66963e1a0.zip
FreeBSD-src-83d14553fcd8bd25049ae5b34b34acc66963e1a0.tar.gz
Don't update p_stat in exit1() to SZOMB until after releasing the allproc
lock. Otherwise, if we block on the backing mutex while releasing the allproc lock, then when we resume, we will be at SRUN, and we will stay that way all the way through cpu_exit. As a result, our parent will never harvest us.
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index a57b914..1c03e7b 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -267,10 +267,16 @@ exit1(p, rv)
lockmgr(&allproc_lock, LK_EXCLUSIVE, NULL, CURPROC);
LIST_REMOVE(p, p_list);
LIST_INSERT_HEAD(&zombproc, p, p_list);
- p->p_stat = SZOMB;
LIST_REMOVE(p, p_hash);
lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC);
+ /*
+ * We have to wait until after releasing this lock before
+ * changing p_stat. If we block on a mutex while waiting to
+ * release the allproc_lock, then we will be back at SRUN when
+ * we resume here and our parent will never harvest us.
+ */
+ p->p_stat = SZOMB;
q = LIST_FIRST(&p->p_children);
if (q) /* only need this if any child is S_ZOMB */
OpenPOWER on IntegriCloud