Shawn Clifford
2009-Jun-16 19:23 UTC
[dtrace-discuss] Modify the excname/fname of the Dtrace process?
I''d like to modify the executable name for the process that is running Dtrace. I have a Dtrace script running in the background all the time, and would like to wipeout the ''dtrace -s ...'' and replace it with a single string. I''ve tried the following, which of course doesn''t work. Can this even be done? #!/usr/sbin/dtrace -s #pragma D option destructive #pragma D option quiet dtrace:::BEGIN { self->parent = execname; self->mypid = curpsinfo->pr_pid; printf("Exec_name = %s PID = %d\n", execname, curpsinfo->pr_pid); copyoutstr("daemon", curpsinfo->pr_fname, 6); self->parent = execname; self->mypid = curpsinfo->pr_pid; printf("Exec_name = %s PID = %d\n", execname, curpsinfo->pr_pid); } -- This message posted from opensolaris.org
Jonathan Adams
2009-Jun-16 21:15 UTC
[dtrace-discuss] Modify the excname/fname of the Dtrace process?
On Tue, Jun 16, 2009 at 12:23:46PM -0700, Shawn Clifford wrote:> I''d like to modify the executable name for the process that is running > Dtrace. I have a Dtrace script running in the background all the > time, and would like to wipeout the ''dtrace -s ...'' and replace it > with a single string. > > I''ve tried the following, which of course doesn''t work. Can this even > be done? > > #!/usr/sbin/dtrace -s > > #pragma D option destructive > #pragma D option quiet > > dtrace:::BEGIN > { > self->parent = execname; > self->mypid = curpsinfo->pr_pid; > printf("Exec_name = %s PID = %d\n", execname, curpsinfo->pr_pid); > > copyoutstr("daemon", curpsinfo->pr_fname, 6); > > self->parent = execname; > self->mypid = curpsinfo->pr_pid; > printf("Exec_name = %s PID = %d\n", execname, curpsinfo->pr_pid); > }Sorry, the execname is fixed in the kernel at exec(1M) time. The best you could do would be to make a hardlink or copy of /usr/sbin/dtrace, and change your #! line to invoke that instead. Cheers, - jonathan