12.2 Eliminating dtrace Interference

If you trace every call to the write() system call, you cause a cascade of output. Each call causes the dtrace command to call write() as it displays the output, and so on. This feedback loop is a good example of how dtrace can interfere with the desired data. You can use a simple predicate to prevent such unwanted data from being traced:

/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. Therefore the predicate /pid != $pid/ ensures that the script does not trace any events related to itself.