PERFORCE change 156859 for review

Robert Watson rwatson at FreeBSD.org
Thu Jan 29 06:21:31 PST 2009


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

Change 156859 by rwatson at 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) {


More information about the p4-projects mailing list