On Sun, Oct 05, 2008 at 10:17:27PM -0700, Adam Leventhal wrote:
> > Without the Prelease() call, a process is killed if its pid is fed to
> > this program.  With the Prelease() call, a process continues to run.
> 
> 
> Doing a little DTrace investigation, I see that we unset PR_KLC in
> Prelease() from restore_tracing_flags(). Here's the invocation I used:
> 
> # dtrace -c '/usr/sbin/i86/dtrace -n agsajg -c date' -n 'pid 
> $target::P*setflags:entry{ printf("%x", arg1); }' -Z
> 
> Perhaps fixing this would be as simple as passing PRELEASE_KILL as the
> flag parameter to Prelease().
> 
> Adam

Yes.  Basically this:

     } else {
                dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid);
                rflag = 0; /* apply kill or run-on-last-close */
     }

should be this:

     } else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) {
                dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid);
                rflag = PRELEASE_KILL; /* apply kill-on-last-close */
     } else {
                dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid);
                rflag = 0; /* apply run-on-last-close */
     }

The Prelease() flags are:

 *      PRELEASE_CLEAR  Clear all tracing flags.
 *      PRELEASE_RETAIN Retain current tracing flags.
 *      PRELEASE_HANG   Leave the process stopped and abandoned.
 *      PRELEASE_KILL   Terminate the process with SIGKILL.

but in the absence of those flags (0), the behavior is to
restore the flags as they were found when we originally attached
(that is what restore_tracing_flags() does).

-Mike

-- 
Mike Shapiro, Sun Microsystems Fishworks. blogs.sun.com/mws/
_______________________________________________
dtrace-discuss mailing list
[email protected]

Reply via email to