On Tue, Jan 06, 2009 at 12:44:54AM -0800, marc claeys
wrote:> Hi all,
>
> The space between the T and the r is not a typo.
> The problem is the following. I want to dtrace a process by
> means of its pid. When the process exits the dtrace must
> also exit.
> The problem is that by the time the dtrace probes fire, the process
> could already have gone, and hence the exit probe will never fire.
# dtrace -p 1234 -n ''sched:::on-cpu/pid == $target/{}''
will attach to pid 1234, put ''1234'' in $target, trace all
entries onto a
cpu, and then exit when 1234 dies.
> Is there a way of checking if the process with a certain pid does
> still exist?
>
> I tried by adding a dummy pid probe. Sometimes I get ": failed to grab
> process <pid>''
> but sometimes I do not, and the dtrace process last forever.
>
> BTW: tracing a process exit isn''t easy as well: rexit only fires
when
> the porcess calls
> exit but when a signal is sent.... you always get lwp_exit fired, how
> to know this will
> cause the process to exit and not a single thread?
You should look at the "proc" provider; proc:::exit fires when a
process dies,
no matter the cause.
Cheers,
- jonathan