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.
This commit is contained in:
John Baldwin 2000-12-01 03:42:17 +00:00
parent 723aebe85e
commit 472fd56ea5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69435

View File

@ -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 */