[dtrace-discuss] Help pid provider follow child processes

Vladimir Marek Vladimir.Marek at Sun.COM
Wed May 7 13:31:52 PDT 2008


> I just tried stop() as you suggested and I thing something bad is happening
> when you are using this action. Please see following. Having this two very 
> simple dtrace scripts:
> 
> #!/usr/sbin/dtrace -wqs
> /*this is master.d dscript file*/
> 
> proc:::exec-success

My unqualified guess is that exec-success probe is executed right after
the process image is replaced by new one, which is way before any
symbols are loaded from any libraries. So setting in the second script
pid$1:::entry sets probes only in symbols defined in the binary itself.

I tried to create another scenario with third dtrace script in the
middle between master and helper and it seems to work as requested.

I'm attaching the scripts.

On the side note, if you don't want to see realtime linker in the
output, you can try to run the binary with LD_BIND_NOW environment set
(see man ld.so.1)

Hope this helps

-- 
	Vlad
-------------- next part --------------
#!/usr/sbin/dtrace -wqs
/*this is master.d dscript file*/

proc:::exec-success
/(execname == "myprog") || its_ours[ppid]/
{
    stop(); /*try to comment this line*/
    its_ours[pid] = 1;
    printf("proccess is %s, %d, %d\n",execname,pid,ppid);
    system("./middle.d %d &",pid);
}
-------------- next part --------------
#pragma D option destructive
#pragma D option quiet

dtrace:::BEGIN
{
    system("prun %d", $1); /*try to comment this line*/
}

pid$1:::entry
{
  self->indent++;
  printf("%*s--> %s(%d)\n",2*self->indent," ",probefunc,tid);
}

pid$1:::return
{
  printf("%*s<-- %s(%d)\n",2*self->indent," ",probefunc,tid);
  self->indent = (self->indent-1 < 0 ? 0 : self->indent-1);
}
-------------- next part --------------
#!/usr/sbin/dtrace -s
#pragma D option destructive
#pragma D option quiet

dtrace:::BEGIN
{
	system("prun %d", $1); /*try to comment this line*/
	printf ("pid %d armed\n", pid);
}

pid$1::main:entry
{
	stop();
	system("dtrace -s helper.d %d > _%s_%d &",pid,execname,pid);
	exit(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 193 bytes
Desc: not available
Url : http://mail.opensolaris.org/pipermail/dtrace-discuss/attachments/20080507/e1bf4ea6/attachment.bin 


More information about the dtrace-discuss mailing list