Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jan 2009 14:21:28 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 156859 for review
Message-ID:  <200901291421.n0TELSAx080526@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help

http://perforce.freebsd.org/chv.cgi?CH=156859

Change 156859 by rwatson@rwatson_freebsd_capabilities on 2009/01/29 14:20:44

	Move down the process descriptor exemption in the wait loop, and
	change the logic slightly: only exempt processes with process
	descriptors from visibility in wait4() if they aren't being
	debugged with ptrace().  Otherwise decidedly odd things happen
	when gdb fails to detach the process and exits, as the parent
	process becomes init while it still has a process descriptor.

Affected files ...

.. //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_exit.c#12 edit

Differences ...

==== //depot/projects/trustedbsd/capabilities/src/sys/kern/kern_exit.c#12 (text+ko) ====

@@ -872,15 +872,6 @@
 		}
 
 		/*
-		 * If a process has a process descriptor, then it won't be
-		 * picked up by wait4().
-		 */
-		if (p->p_procdesc != NULL) {
-			PROC_UNLOCK(p);
-			continue;
-		}
-
-		/*
 		 * This special case handles a kthread spawned by linux_clone
 		 * (see linux_misc.c).  The linux_wait4 and linux_waitpid
 		 * functions need to be able to distinguish between waiting
@@ -894,6 +885,17 @@
 			continue;
 		}
 
+		/*
+		 * If a process has a process descriptor, then it won't be
+		 * picked up by wait4().  Unless it's being debugged, in
+		 * which case the debugging process will need to manage it
+		 * with waitpid().
+		 */
+		if (p->p_procdesc != NULL && p->p_oppid == 0) {
+			PROC_UNLOCK(p);
+			continue;
+		}
+
 		nfound++;
 		PROC_SLOCK(p);
 		if (p->p_state == PRS_ZOMBIE) {



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