From owner-p4-projects@FreeBSD.ORG Thu Jan 29 14:21:29 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 53EA91065673; Thu, 29 Jan 2009 14:21:29 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0514B106566B for ; Thu, 29 Jan 2009 14:21:29 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E3BE88FC0A for ; Thu, 29 Jan 2009 14:21:28 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n0TELSP8080528 for ; Thu, 29 Jan 2009 14:21:28 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n0TELSAx080526 for perforce@freebsd.org; Thu, 29 Jan 2009 14:21:28 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Thu, 29 Jan 2009 14:21:28 GMT Message-Id: <200901291421.n0TELSAx080526@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 156859 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2009 14:21:31 -0000 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) {