Eliminating dtrace
Interference
If you trace every call to the write
system call, you will cause a cascade of output. Each call to write
causes the dtrace
command to call write
as it displays the output, and so on. 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 prevent these unwanted data from being traced:
syscall::write:entry /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 the running of this script itself.