DTRACE_PROC(4)
π DTRACE_PROC(4) β the dtrace_proc manual, but make it make sense π
okay bestie, you found DTRACE_PROC(4) in the Kernel Interfaces Manual and you're like "what is this" β don't worry, I got you. this is the page for dtrace_proc, and by the end you're gonna be obsessed, fr fr. π¦
β¨ NAME β¨
dtrace_proc β a DTrace provider for tracing events related to user processes
π SYNOPSIS π
proc:::create(struct proc *, struct proc *, int);
proc:::exec(char *);
proc:::exec-failure(int);
proc:::exec-success(char *);
proc:::exit(int);
proc:::signal-clear(int, ksiginfo_t *);
proc:::signal-discard(struct thread *, struct proc *, int);
proc:::signal-send(struct thread *, struct proc *, int);
πΈ DESCRIPTION πΈ
The DTrace proc provider gives you insight into events related to user processes: process and thread creation and termination events, and process signalling. it's giving "I see everything your processes are doing" and honestly? iconic. π
The proc:::create() probe fires when a user process is created via the fork(2), vfork(2), pdfork(2), or rfork(2) system calls. lowkey important: kernel processes created with the kproc(9) KPI will not trigger this probe. no cap. π
- the first two arguments are the new child process and its parent, respectively
- the third argument is a mask of
rfork(2)flags indicating which process resources are to be shared between the parent and child processes
The proc:::exec() probe fires when a process attempts to execute a file. its argument is the specified filename for the file. if the attempt fails because of an error, the proc:::exec-failure() probe will subsequently fire, providing the corresponding errno(2) value in its first argument. otherwise, the proc:::exec-success() probe will fire. slay, one or the other, never both. β¨
The proc:::exit() probe fires when a process exits or is terminated. its argument is the corresponding SIGCHLD signal code; valid values are documented in the siginfo(3) manual page and defined in signal.h. for example, when a process exits normally, the value of args[0] will be CLD_EXITED.
The proc:::signal-send() probe fires when a signal is about to be sent to a process. the proc:::signal-discard() probe fires when a signal is sent to a process that ignores it. heads up: this probe will fire after the proc:::signal-send() probe for the signal in question. the arguments to these probes are the thread and process to which the signal will be sent, and the signal number of the signal. valid signal numbers are defined in the signal(3) manual page.
The proc:::signal-clear() probe fires when a pending signal has been cleared by one of the sigwait(2), sigtimedwait(2), or sigwaitinfo(2) system calls. its arguments are the signal number of the cleared signal, and a pointer to the corresponding signal information. the siginfo_t for the signal can be obtained from args[1]->ksi_info. the way that is so specific and usefulβ¦ we love to see it. π
π ARGUMENTS π
so, though the proc provider probes use native FreeBSD argument types, standard D types for processes and threads are available. these are psinfo_t and lwpsinfo_t respectively, and are defined in /usr/lib/dtrace/psinfo.d. this file also defines two global variables, curpsinfo and curlwpsinfo, which provide representations of the current process and thread using these types. π«Ά
π§ the fields of psinfo_t are:
int pr_nlwpβ number of threads in the process.pid_t pr_pidβ process ID.pid_t pr_ppidβ process ID of the parent process, or0if the process does not have a parent.pid_t pr_pgidβ process ID of the process group leader.pid_t pr_sidβ session ID, or0if the process does not belong to a session.pid_t pr_uidβ real user ID.pid_t pr_euidβ effective user ID.pid_t pr_gidβ real group ID.pid_t pr_egidβ effective group ID.uintptr_t pr_addrβ pointer to thestruct procfor the process.string pr_psargsβ process arguments.u_int pr_arglenβ length of the process argument string.u_int pr_jailidβ jail ID of the process.
π¦ the fields of lwpsinfo_t are:
id_t pr_lwpidβ thread ID.int pr_flagβ thread flags.int pr_priβ real scheduling priority of the thread.char pr_stateβ currently always0.char pr_snameβ currently alwaysββ?.short pr_syscallβ currently always0.uintptr_t pr_addrβ pointer to thestruct threadfor the thread.uintptr_t pr_wchanβ current wait address on which the thread is sleeping.
π FILES π
/usr/lib/dtrace/psinfo.dβ DTrace type and translator definitions for theprocprovider.
β EXAMPLES β
the following script logs process execution events as they occur. it's short, it's cute, it works:
#pragma D option quiet
proc:::exec-success
{
printf("%s", curpsinfo->pr_psargs);
}
wait, bestie, read this before you ship it: note that thepr_psargsfield is subject to the limit defined by thekern.ps_arg_cache_limitsysctl. in particular, processes with an argument list longer than the value defined by this sysctl cannot be logged in this way. π so if your args are huge, this ain't it.
π COMPATIBILITY π
the proc provider in FreeBSD is not compatible with the proc provider in Solaris. not even a little. in particular, FreeBSD uses the native struct proc and struct thread types for probe arguments rather than translated types. additionally, a number of proc provider probes found in Solaris are not currently available on FreeBSD. so don't copy-paste your Solaris scripts and expect main character energy. π
π SEE ALSO π
dtrace(1), errno(2), fork(2), pdfork(2), rfork(2), vfork(2), siginfo(3), signal(3), dtrace_sched(4), kproc(9)
π HISTORY π
The proc provider first appeared in FreeBSD 7.1.
π AUTHORS π
This manual page was written by Mark Johnston <markj@FreeBSD.org>.
okay periodt, that's the whole page, you ate it. π β¨ this one came from the Debian manual set, dated April 17, 2016 β so if you're citing it, that's your source and date, bestie. go forth and trace those processes, you've got this. π¦πΈπ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms