OPENPROC(3)
π OPENPROC(3) π β openproc, closeproc
okay bestie, welcome to the Linux Programmer's Manual page for openproc and closeproc. this is the one that gets your process info from /proc/. sit down, hydrate, we're doing this π
β¨ NAME β¨
openproc, closeproc β initialize process information from /proc/ π«Ά
πΈ SYNOPSIS πΈ
#include <proc/readproc.h>
PROCTAB* openproc (int flags, ... );
void closeproc (PROCTAB* PT);
πΈ SYNOPSIS πΈ (yes it's here twice, the manpage said so, i don't make the rules π)
so openproc is the girl who sets up your PROCTAB structure. once it's initialized, you can hit it with iterated readproc calls to get all the tea on the current processes. depending on what flags you pass, openproc might need a second argument, or a second and third argument (more on that below π).
closeproc is the responsible bestie: it closes all files opened by openproc and deallocates all the memory openproc allocated. no leaks, we don't do that here β¨
and btw, the PROCTAB structure is defined in <proc/readproc.h> π
π¦ RETURN VALUE π¦
openproc hands you back a pointer to a PROCTAB structure β slay β or NULL if something goes wrong. and ngl, NULL usually means the process can't read /proc. not iconic. π
π FLAGS π
the whole personality of openproc is controlled by this flag set, and you can OR them together. there are three different kinds of flags, bestie, keep up:
- group one decides which information gets read from
/proc/#pidfor each process. - group two narrows down which processes get their info read, by giving it a list of criteria β and heads up, only one of these can be enacted for an
opendircall. - group three also restricts stuff, but doesn't need arguments. these can be used together again π
now the flags themselves, one by one, no skipping, periodt:
PROC_FILLMEMβ read information from/proc/#pid/statmPROC_FILLCOMβ allocate thecmdlinepart ofproc_tand read information from/proc/#pid/cmdlinePROC_FILLENVβ allocate theenvironpart ofproc_tand read information from/proc/#pid/environPROC_FILLUSRβ resolve user ids to names via/etc/passwdPROC_FILLGRPβ resolve group ids to names via/etc/groupPROC_FILLSTATUSβ read information from/proc/#pid/statusPROC_FILLSTATβ read information from/proc/#pid/statPROC_FILLARGβ equivalent toPROC_FILLCOMPROC_FILLCGROUPβ alloc and fill in cgroupPROC_FILLSUPGRPβ resolve supplementary group id -> group namePROC_FILLOOMβ fill inproc_toom_scoreandoom_adjPROC_FILLNSβ fill inproc_tnamespace informationPROC_FILLSYSTEMDβ fill inproc_tsystemd informationPROC_LOOSE_TASKSβ treats threads as if they were processes (yes really, threads get main character treatment π)PROC_PID(2nd argumentpid_t* pidlist) β lookup only processes whose pid is contained inpidlist(the list is terminated with0)PROC_UID(argumentsuid_t* uidlist,int n) β lookup only processes whose user id is contained inuidlist(wherenis the number of uids contained in the list)PROC_EDITCGRPCVTβ edit cgroup as single vectorPROC_EDITCMDLCVTβ edit cmdline as single vectorPROC_EDITENVRCVTβ edit environ as single vector
π NOTE π
bestie listen. only one of the flags that need extra arguments β that's PROC_{PID,UID} β may be used at a time. one. not two. i'm serious. π«
π SEE ALSO π
readproc(3)readproctab(3)/proc//usr/include/proc/readproc.h
π REPORTING BUGS π
found a bug? please send bug reports to procps@freelists.org β they want to hear from you fr fr π«Ά
this has been a page from the Linux Manpage, dated 14 July 2014, titled OPENPROC(3) β and that's the whole vibe check. bye bestie, go close your file descriptors πβ¨π
π¦ where this page comes from
- centos-stream 9: procps-ng-devel 3.3.17-15.el9 Β· GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
- centos-stream 9: procps-ng-devel 3.3.17-15.el9 Β· GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+
- ubuntu jammy: procps 2:3.3.17-6ubuntu2 Β· LGPL-2.1-or-later
- ubuntu jammy: procps 2:3.3.17-6ubuntu2.1 Β· LGPL-2.1-or-later
- Copyright 1996 Helmut Geyer <Helmut.Geyer@iwr.uni-heidelberg.de>
- Copyright 2014 Jaromir Capik <jcapik@redhat.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms