svn commit: r270294 - stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace

Mark Johnston markj at FreeBSD.org
Fri Aug 22 15:00:48 UTC 2014


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.


More information about the svn-src-all mailing list