DTrace User Guide

Eliminating dtrace Interference

If you trace every call to the write system call, you will cause a cascade of output. Each call to the write() function causes the dtrace command to call the write() function as it displays the output. This feedback loop is a good example of how the dtrace command can interfere with the desired data. You can use a simple predicate to avoid this behavior, as shown in the following example:

/pid != $pid/
	printf("%s", stringof(copyin(arg1, arg2)));

The $pid macro variable expands to the process identifier of the process that enabled the probes. The pid variable contains the process identifier of the process whose thread was running on the CPU where the probe was fired. The predicate /pid != $pid/ ensures that the script does not trace any events related to the running of this script.