summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exit.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-04-02 19:35:36 +0000
committerkib <kib@FreeBSD.org>2012-04-02 19:35:36 +0000
commitff6239a557dad09f5ff2c55951b55a047430c529 (patch)
tree47fdb8c8b3e2abe9f0fc88e1947613dc77305ff1 /sys/kern/kern_exit.c
parent9ad701f91fade3ec9d7805722dc0ccb8410f3498 (diff)
downloadFreeBSD-src-ff6239a557dad09f5ff2c55951b55a047430c529.zip
FreeBSD-src-ff6239a557dad09f5ff2c55951b55a047430c529.tar.gz
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
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r--sys/kern/kern_exit.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index a923c02..2f3fb3a 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -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;
OpenPOWER on IntegriCloud