From owner-svn-src-head@FreeBSD.ORG Thu Aug 7 16:48:28 2014 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DD90EAB8; Thu, 7 Aug 2014 16:48:28 +0000 (UTC) Received: from gw.catspoiler.org (gw.catspoiler.org [75.1.14.242]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BEF9A26B4; Thu, 7 Aug 2014 16:48:28 +0000 (UTC) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.13.3/8.13.3) with ESMTP id s77GmI98043796; Thu, 7 Aug 2014 09:48:22 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <201408071648.s77GmI98043796@gw.catspoiler.org> Date: Thu, 7 Aug 2014 09:48:18 -0700 (PDT) From: Don Lewis Subject: Re: svn commit: r269656 - in head: bin/ps sys/kern sys/sys To: kib@FreeBSD.org In-Reply-To: <53e31309.5581.568424c9@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2014 16:48:29 -0000 On 7 Aug, Konstantin Belousov wrote: > Author: kib > Date: Thu Aug 7 05:47:53 2014 > New Revision: 269656 > URL: http://svnweb.freebsd.org/changeset/base/269656 > > Log: > Correct the problems with the ptrace(2) making the debuggee an orphan. > One problem is inferior(9) looping due to the process tree becoming a > graph instead of tree if the parent is traced by child. Another issue > is due to the use of p_oppid to restore the original parent/child > relationship, because real parent could already exited and its pid > reused (noted by mjg). > > Add the function proc_realparent(9), which calculates the parent for > given process. It uses the flag P_TREE_FIRST_ORPHAN to detect the head > element of the p_orphan list and than stepping back to its container > to find the parent process. If the parent has already exited, the > init(8) is returned. > > Move the P_ORPHAN and the new helper flag from the p_flag* to new > p_treeflag field of struct proc, which is protected by proctree lock > instead of proc lock, since the orphans relationship is managed under > the proctree_lock already. > > The remaining uses of p_oppid in ptrace(PT_DETACH) and process > reapping are replaced by proc_realparent(9). Changing the parent process has always seemed like a hack to me. It seems like the debugger should register itself as an additional parent.