1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-29 16:44:03 +00:00

When process exists, not only the children shall be reparented to

init, but also the orphans shall be removed from the orphan list,
because the list header is destroyed.

Reported and tested by:	pho
MFC after:	3 days
This commit is contained in:
Konstantin Belousov 2012-04-02 19:35:36 +00:00
parent 2e39e24f64
commit 5085ecb75a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=233809

View File

@ -430,6 +430,13 @@ exit1(struct thread *td, int rv)
if (q->p_flag & P_TRACED) {
struct thread *temp;
/*
* Since q was found on our children list, the
* proc_reparent() call moved q to the orphan
* list due to present P_TRACED flag. Clear
* orphan link for q now while q is locked.
*/
clear_orphan(q);
q->p_flag &= ~(P_TRACED | P_STOPPED_TRACE);
FOREACH_THREAD_IN_PROC(q, temp)
temp->td_dbgflags &= ~TDB_SUSPEND;
@ -438,6 +445,15 @@ exit1(struct thread *td, int rv)
PROC_UNLOCK(q);
}
/*
* Also get rid of our orphans.
*/
while ((q = LIST_FIRST(&p->p_orphans)) != NULL) {
PROC_LOCK(q);
clear_orphan(q);
PROC_UNLOCK(q);
}
/* Save exit status. */
PROC_LOCK(p);
p->p_xthread = td;