PGET(9)
π PGET(9) β the Kernel Developer's Manual, bestie edition β¨
okay so real talk, this one's from the kernel dev manual and it's literally called pget β the whole vibe is "find a process by number" π
πΈ NAME
pget β locate a process by number, fr fr π
β¨ SYNOPSIS
#include <sys/param.h>
#include <sys/proc.h>
int
pget(pid_t pid, int flags, struct proc **pp);
π DESCRIPTION
okay so here's the tea β β this function takes a pid as its argument, and that pid can be either a process id or a thread id, and it fills a pointer to the proc structure into *pp. in the thread-id case, it goes looking for the process that owns the specified thread. the actual searching is done by calling pfind(9). iconic delegation honestly π«Ά
now the important part, don't skip this π the found process is returned locked. except for the PGET_HOLD case, where it comes back unlocked (but held). and depending on the flags argument, pget() can do some extra little manipulations on top of that. main character energy π
the flags argument is the logical OR of some subset of these beauties:
PGET_HOLDβ if set, the found process will be held and unlocked πPGET_CANSEEβ if set, the found process gets checked for its visibility. seep_cansee(9)πPGET_CANDEBUGβ if set, the found process gets checked for its debuggability. seep_candebug(9)πPGET_ISCURRENTβ if set, the found process gets checked that it matches the current process context π―PGET_NOTWEXITβ if set, the found process gets checked that it does not have the process flagP_WEXITset πͺPGET_NOTINEXECβ if set, the found process gets checked that it does not have the process flagP_INEXECset πββοΈPGET_NOTIDβ if set, pid is not assumed as a thread id for values larger thanPID_MAXπPGET_WANTREADβ if set, the found process gets checked that the caller may get read access to its structure. it's a shorthand for (PGET_HOLD|PGET_CANDEBUG|PGET_NOTWEXIT) β¨
π₯ RETURN VALUES
if the process is found in the specified way, you get zero back β slay π otherwise you get an appropriate error code. no cap, that's the whole contract π
π¦ SEE ALSO
p_candebug(9), p_cansee(9), pfind(9) β go read these too, iykyk π
and that's the page!! π this little gem is from the Debian edition of the manual, dated May 3, 2014 β oldie but a goodie, and it still ate π β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 2011 Sergey Kandaurov
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms