KTRACE(2) BSD Programmer's Manual KTRACE(2)
NAME
ktrace - enable kernel process tracing
SYNOPSIS
#include <sys/ktrace.h>
int
ktrace(const char *fname, int ops, int facs, pidt pid)
DESCRIPTION
The ktrace() function is used to enable or disable kernel trace logging
for the specified file, process, or process group. The kernel operations
that can be traced include system calls, namei translations, signal pro-
cessing, and I/O. Once tracing is enabled, trace data will be logged un-
til either the process exits or the trace point is cleared.
Process groups are specified by passing a negative value as the pid.
Kernel trace data is logged to the file specified by fname. The ops vari-
able is one of: KTROP_SET, KTROP_CLEAR, KTROP_CLEARFILE. The facs vari-
able is a mask of the following options that specify what you want
logged: KTRFAC_SYSCALL, KTRFAC_SYSRET, KTRFAC_NAMEI, KTRFAC_GENIO,
KTRFAC_PSIG.
RETURN VALUES
Zero is returned if the operation was successful; -1 is returned if an
error occurs, with a more specific error code being placed in the global
variable errno.
ERRORS
Ktrace() will fail if and the file will remain unchanged if:
[EACCES] The file cannot be written.
[EPERM] You do not have permission to access the process or pro-
cess group.
[EINVAL] The facs flag is invalid.
[ESRCH] The process id or process group was not found.
SEE ALSO
ktrace(1)
BSDI BSD/386 March 26, 1993 1