PGET(9)
π PGET β locate a process by number π
okay bestie, welcome to pget(9), straight out of the Kernel Developer's Manual (yes we read kernel docs for fun now, it's a whole personality) β¨
π NAME π
pget β find a process by its number, fr fr π
β¨ SYNOPSIS β¨
#include <sys/param.h>
#include <sys/proc.h>
int
pget(pid_t pid, int flags, struct proc **pp);
like, that's the whole vibe. three args, one pointer-to-pointer, zero chill π«Ά
π¦ DESCRIPTION π¦
so the way this works is: you hand pget() a pid, and that pid can be either a process id or a thread id β it's flexible like that πββοΈ β and then it fills in a pointer to the proc structure into *pp. and if you gave it a thread id? no worries, it goes looking for the process that owns that thread. queen behavior π
the actual finding is done by calling the pfind(9) function, iykyk.
now here's the part you gotta remember, bestie: the found process comes back LOCKED. π but if you passed PGET_HOLD, it comes back unlocked instead (but held β which is a whole different thing, don't mix them up π).
and depending on what you put in flags, pget() will do extra little manipulations on top. it's giving β¨customizableβ¨.
the flags argument is the logical OR of some subset of these:
PGET_HOLDβ if set, the found process gets held and unlocked. (the opposite-lock vibe, we love her πΈ)PGET_CANSEEβ if set, the found process gets its visibility checked. seep_cansee(9)πPGET_CANDEBUGβ if set, the found process gets checked for debuggability. seep_candebug(9)πPGET_ISCURRENTβ if set, the found process gets checked that it matches the current process context. "is it me? am I the drama?" πͺ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,pidis 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 literally a shorthand for(PGET_HOLD | PGET_CANDEBUG | PGET_NOTWEXIT)π
π RETURN VALUES π
if the process is found in the specified way β zero gets returned, slay β¨
otherwise β an appropriate error code comes back instead. not slay π
π SEE ALSO π
p_candebug(9), p_cansee(9), pfind(9) β go read your siblings, they're iconic too π«Ά
and that's the whole page, bestie π this one's from Debian, dated May 3, 2014 β vintage, honestly. go lock a process responsibly, mwah ππ
π¦ 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) 2011 Sergey Kandaurov
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms