Skip to content

Getting dtrace to exit with the same status as the traced program

July 9, 2008

Today’s dtrace one-liner is how do you get dtrace to exit with the same exit code as the program you are tracing so you can use it in a script?

There are going to be many ways to solve this. Mine is simply to include a probe for the exit system call and then pass arg0 of the exit system call to the dtrace exit() function:

while dtrace -n ‘syscall::*exit:entry /pid == $target / { trace(arg0); exit(arg0) } fbt:autofs::return / pid == $target / { stack(5); trace(arg1) }’ -c ‘ls -d /home/cjg’ do umountall -F nfs svcadm restart autofs done 

Simple and allows the test to run and run until the problem is seen.

Advertisements

From → Solaris

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: