Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Apr 2012 19:35:36 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r233809 - head/sys/kern
Message-ID:  <201204021935.q32JZaPI013648@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Apr  2 19:35:36 2012
New Revision: 233809
URL: http://svn.freebsd.org/changeset/base/233809

Log:
  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

Modified:
  head/sys/kern/kern_exit.c

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Mon Apr  2 19:34:56 2012	(r233808)
+++ head/sys/kern/kern_exit.c	Mon Apr  2 19:35:36 2012	(r233809)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204021935.q32JZaPI013648>