Target Process ID

Use the $target macro variable to create scripts that can be applied to a particular user process of interest that is selected on the dtrace command line using the -p option or created using the -c option. The D programs specified on the command line or using the -s option are compiled after processes are created or grabbed and the $target variable expands to the integer process-ID of the first such process. For example, the following D script could be used to determine the distribution of system calls executed by a particular subject process:

syscall:::entry
/pid == $target/
{
@[probefunc] = count();
}

To determine the number of system calls executed by the date(1) command, save the script in the file syscall.d and execute the following command: