From owner-svn-src-head@FreeBSD.ORG Tue Aug 26 19:32:18 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2D151114; Tue, 26 Aug 2014 19:32:18 +0000 (UTC) Received: from h2.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "funkthat.com", Issuer "funkthat.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 0A03A3004; Tue, 26 Aug 2014 19:32:17 +0000 (UTC) Received: from h2.funkthat.com (localhost [127.0.0.1]) by h2.funkthat.com (8.14.3/8.14.3) with ESMTP id s7QJWAV9026027 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Aug 2014 12:32:11 -0700 (PDT) (envelope-from jmg@h2.funkthat.com) Received: (from jmg@localhost) by h2.funkthat.com (8.14.3/8.14.3/Submit) id s7QJWAaH026026; Tue, 26 Aug 2014 12:32:10 -0700 (PDT) (envelope-from jmg) Date: Tue, 26 Aug 2014 12:32:10 -0700 From: John-Mark Gurney To: John Baldwin Subject: Re: svn commit: r270444 - in head/sys: kern sys Message-ID: <20140826193210.GL71691@funkthat.com> References: <201408240904.s7O949sI083660@svn.freebsd.org> <1815651.yxLDiBYvJT@ralph.baldwin.cx> <20140825223034.GE71691@funkthat.com> <201408261509.26815.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201408261509.26815.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Operating-System: FreeBSD 7.2-RELEASE i386 X-PGP-Fingerprint: 54BA 873B 6515 3F10 9E88 9322 9CB1 8F74 6D3F A396 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.2 (h2.funkthat.com [127.0.0.1]); Tue, 26 Aug 2014 12:32:11 -0700 (PDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Mateusz Guzik , src-committers@freebsd.org, Mateusz Guzik X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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: Tue, 26 Aug 2014 19:32:18 -0000 John Baldwin wrote this message on Tue, Aug 26, 2014 at 15:09 -0400: > On Monday, August 25, 2014 6:30:34 pm John-Mark Gurney wrote: > > John Baldwin wrote this message on Mon, Aug 25, 2014 at 13:35 -0400: > > > On Monday, August 25, 2014 07:02:41 PM Mateusz Guzik wrote: > > > > On Mon, Aug 25, 2014 at 10:23:19AM -0400, John Baldwin wrote: > > > > > On Sunday, August 24, 2014 09:04:09 AM Mateusz Guzik wrote: > > > > > > Author: mjg > > > > > > Date: Sun Aug 24 09:04:09 2014 > > > > > > New Revision: 270444 > > > > > > URL: http://svnweb.freebsd.org/changeset/base/270444 > > > > > > > > > > > > Log: > > > > > > Fix getppid for traced processes. > > > > > > > > > > > > Traced processes always have the tracer set as the parent. > > > > > > Utilize proc_realparent to obtain the right process when needed. > > > > > > > > > > Are you sure this won't break things? I know of several applications that > > > > > expect a debugger to be the parent when attached and change behavior as a > > > > > result (e.g. inserting a breakpoint on an assertion failure rather than > > > > > generating a core). > > > > > > > > Well, this is what linux and solaris do. > > > > > > Interesting. > > > > > > > I don't feel strongly about this change. If you really want I'm happy to > > > > revert. > > > > > > In general I'd like to someday have the debugger-debuggee relationship not > > > override parent-child and this is a step in that direction. However, this > > > will break existing applications, so this needs to be clearly documented in > > > the release notes. In addition, we should probably advertise how a process > > > can correctly determine if it is being run under a debugger (right now you can > > > do 'getppid()' and use strcmp or strstr on the p_comm of that pid so you can > > > do different things for "gdb" vs "gcore", etc. so just checking P_TRACED from > > > kinfo_proc wouldn't be equivalent in functionality) > > > > But what about when you attach gdb to a running process... That > > doesn't magicly make the now debugged process a child of gdb does it? > > % cat hello.c > #include > > int > main() > { > printf("hello world\n"); > (void)getchar(); > return (0); > } > % cc -g hello.c -o hello > % ./hello > hello world > load: 9.81 cmd: hello 42599 [ttyin] 1.67r 0.00u 0.00s 0% 1056k > > < different window > > > % ps -O ppid -p `pgrep hello` > PID PPID TT STAT TIME COMMAND > 42599 5340 16 I+ 0:00.00 ./hello > % gdb hello `pgrep hello` > GNU gdb 6.1.1 [FreeBSD] > ... > (gdb) > Suspended > % ps -O ppid -p `pgrep hello` > PID PPID TT STAT TIME COMMAND > 42599 45079 16 TX+ 0:00.00 ./hello Wow, learn something new every day... But doesn't that break apps that use getppid to signal their parent that forked them? -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."