Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Aug 2014 10:59:28 -0400
From:      Mark Johnston <markj@FreeBSD.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   Re: svn commit: r270294 - stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace
Message-ID:  <20140822145928.GA75918@charmander.home>
In-Reply-To: <20140822062207.GK2737@kib.kiev.ua>
References:  <201408211945.s7LJjqST049739@svn.freebsd.org> <20140822062207.GK2737@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Aug 22, 2014 at 09:22:07AM +0300, Konstantin Belousov wrote:
> On Thu, Aug 21, 2014 at 07:45:52PM +0000, Mark Johnston wrote:
> > Author: markj
> > Date: Thu Aug 21 19:45:52 2014
> > New Revision: 270294
> > URL: http://svnweb.freebsd.org/changeset/base/270294
> > 
> > Log:
> >   MFC r269525:
> >   Return 0 for the PPID of threads in process 0, as process 0 doesn't have a
> >   parent process.
> > 
> > Modified:
> >   stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
> > Directory Properties:
> >   stable/10/   (props changed)
> > 
> > Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
> > ==============================================================================
> > --- stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Thu Aug 21 19:42:24 2014	(r270293)
> > +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c	Thu Aug 21 19:45:52 2014	(r270294)
> > @@ -3415,7 +3415,10 @@ dtrace_dif_variable(dtrace_mstate_t *mst
> >  		 */
> >  		return ((uint64_t)curthread->t_procp->p_ppid);
> >  #else
> > -		return ((uint64_t)curproc->p_pptr->p_pid);
> > +		if (curproc->p_pid == proc0.p_pid)
> > +			return (curproc->p_pid);
> > +		else
> > +			return (curproc->p_pptr->p_pid);
> >  #endif
> >  
> >  	case DIF_VAR_TID:
> BTW, does the code look for the parent, or for the debugger of the current
> process ? I mean, should the snippet above use p_pptr or real_parent() ?

It should return the parent of the process; it's effectively an
implementation of getppid() for DTrace scripts. proc_realparent()
requires the proctree lock to be held though, so it can't really be used
here. This code is in the DTrace probe handler, so it runs with
interrupts disabled, and it also could be called from a context where
the shared lock is already held.



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