Skip to content

Instantly share code, notes, and snippets.

@siepkes
Created October 25, 2024 14:36
Show Gist options
  • Save siepkes/6e0e86255e7953abbc47787367215dd5 to your computer and use it in GitHub Desktop.
Save siepkes/6e0e86255e7953abbc47787367215dd5 to your computer and use it in GitHub Desktop.
#!/usr/sbin/dtrace -s
#pragma D option quiet
proc:::exec
/ $1 == curpsinfo->pr_ppid /
{
self->start = timestamp;
}
proc:::exec-success
/self->start/
{
this->now = timestamp;
this->elapsed = this->now - self->start;
printf("Process exited: PID = %d, Parent PID = %d, Start time: %d, End time: %d, Total time: %d, Command = %s\n",
curpsinfo->pr_pid, curpsinfo->pr_ppid, self->start, this->now, this->elapsed, curpsinfo->pr_psargs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment