KINFO_GETALLPROC(3)
π NAME π
okay bestie, meet kinfo_getallproc(3) β the function for getting process information for, like, all the processes from the kernel. no cap, it's the full roster. π
π LIBRARY π
System Utilities Library β that's libutil, link it with -lutil. π
β¨ SYNOPSIS β¨
#include <sys/types.h>
#include <sys/user.h>
#include <libutil.h>
struct kinfo_proc *
kinfo_getallproc(int *cntp);
π«Ά DESCRIPTION π«Ά
So this function is literally used for obtaining process information of all processes from the kernel. every single one. main character energy for the whole process table. π¦
The cntp field is a pointer containing the number of process structures returned. it's giving "here's how many came back". β¨
It's a wrapper around sysctl(3) with the KERN_PROC_PROC mib. While the kernel returns a packed structure, this function expands the data into a fixed record format. yes, it's doing the glow-up from packed to fixed records. π
π RETURN VALUES π
On success, the kinfo_getallproc() function returns a pointer to cntp struct kinfo_proc structures as defined by <sys/user.h>. π«Ά
That pointer was obtained by an internal call to malloc(3) and must be freed by the caller with a call to free(3). bestie, do not forget the free(3) β that's the whole vibe check. π
On failure, the kinfo_getallproc() function returns NULL. and that's it. π
π SEE ALSO π
π HISTORY π
The kinfo_getallproc() function first appeared in FreeBSD 8.3. iconic behavior, honestly. π
π cute little source/version + date sign-off: this page is from Debian, dated May 8, 2020 β mwah πβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2009 Ulf Lilleengen
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms