FreeBSD manual

download PDF document: kinfo_getproc.3.pdf

KINFO_GETPROC(3) FreeBSD Library Functions Manual KINFO_GETPROC(3)
NAME kinfo_getproc - function for getting process information from kernel
LIBRARY System Utilities Library (libutil, -lutil)
SYNOPSIS #include <sys/types.h> #include <sys/user.h> #include <libutil.h>
struct kinfo_proc * kinfo_getproc(pid_t pid);
DESCRIPTION This function is used for obtaining process information from the kernel.
The pid field contains the process identifier. This should be a process that you have privilege to access. This function is a wrapper around sysctl(3) with the KERN_PROC_PID mib. While the kernel returns a packed structure, this function expands the data into a fixed record format.
RETURN VALUES On success the kinfo_getproc() function returns a pointer to a struct kinfo_proc structure as defined by <sys/user.h>. The pointer was obtained by an internal call to malloc(3) and must be freed by the caller with a call to free(3). On failure the kinfo_getproc() function returns NULL.
SEE ALSO free(3), malloc(3), sysctl(3)
HISTORY The kinfo_getproc() function first appeared in FreeBSD 7.0.
FreeBSD 14.0-RELEASE-p11 May 10, 2020 FreeBSD 14.0-RELEASE-p11