1OPENPROC(3) Linux Programmer's Manual OPENPROC(3)
2
3
4
6 openproc, closeproc - initialize process information from /proc/
7
9 #include <proc/readproc.h>
10
11 PROCTAB* openproc (int flags, ... );
12 void closeproc (PROCTAB* PT);
13
14
16 The openproc function initializes a PROCTAB structure which can be used
17 by iterated readproc calls to get information on current processes.
18 Depending on flags, openproc may need a second argument or a second and
19 third argument (see below).
20
21 closeproc closes all files opened by openproc and deallocates the mem‐
22 ory allocated by openproc.
23
24 The PROCTAB structure is defined in <proc/readproc.h>
25
26
28 openproc returns a pointer to a PROCTAB structure, or NULL if an error
29 occurs. This usually means that /proc cannot be read by the process.
30
31
33 The behaviour of openproc is controlled by the following set of flags,
34 which may be ORed together. There are three different kinds of flags.
35 The first group of flags determins which information gets read from
36 /proc/#pid for each process. The second group of flags (of which only
37 one can be enacted for a opendir call) restricts which processes infor‐
38 mation is read for by providing a list of criteria. The third group of
39 flags restricts this as well, but doesn't need arguments. These may be
40 used together again.
41
42
43 PROC_FILLMEM
44 read information from /proc/#pid/statm
45
46 PROC_FILLCOM
47 allocate cmdline part of proc_t and read information from
48 /proc/#pid/cmdline
49
50 PROC_FILLENV
51 allocate environ part of proc_t and read information from
52 /proc/#pid/environ
53
54 PROC_FILLUSR
55 resolve user ids to names via /etc/passwd
56
57 PROC_FILLGRP
58 resolve group ids to names via /etc/group
59
60 PROC_FILLSTATUS
61 read information from /proc/#pid/status
62
63 PROC_FILLSTAT
64 read information from /proc/#pid/stat
65
66 PROC_FILLWCHAN
67 do WCHAN lookup
68
69 PROC_FILLARG
70 equivalent to PROC_FILLCOM
71
72 PROC_FILLCGROUP
73 alloc and fill in cgroup
74
75 PROC_FILLSUPGRP
76 resolve supplementary group id -> group name
77
78 PROC_FILLOOM
79 fill in proc_t oom_score and oom_adj
80
81 PROC_FILLNS
82 fill in proc_t namespace information
83
84 PROC_FILLSYSTEMD
85 fill in proc_t systemd information
86
87 PROC_LOOSE_TASKS
88 threat threads as if they were processes
89
90 PROC_PID (2nd argument pid_t* pidlist)
91 lookup only processes whose pid is contained in pidlist (the list
92 is terminated with 0)
93
94 PROC_UID (arguments uid_t* uidlist, int n)
95 lookup only processes whose user id is contained in uidlist (where
96 n is the number of uids contained in the list)
97
98 PROC_EDITCGRPCVT
99 edit cgroup as single vector
100
101 PROC_EDITCMDLCVT
102 edit cmdline as single vector
103
104 PROC_EDITENVRCVT
105 edit environ as single vector
106
107
109 Only one of the flags needing additional arguments (PROC_{PID,UID}) may
110 be used at a time.
111
112
114 readproc(3), readproctab(3), /proc/, /usr/include/proc/readproc.h,
115
117 Please send bug reports to ⟨procps@freelists.org⟩
118
119
120
121Linux Manpage 14 July 2014 OPENPROC(3)