man-pages/man3/openproc.3.html
2021-03-31 01:06:50 +01:00

241 lines
4.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of OPENPROC</TITLE>
</HEAD><BODY>
<H1>OPENPROC</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 14 July 2014<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
openproc, closeproc - initialize process information from /proc/
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/proc/readproc.h">proc/readproc.h</A>&gt;</B>
<P>
<B>PROCTAB* openproc (int </B><I>flags</I><B>, ... );</B>
<BR>
<B>void closeproc (PROCTAB* </B><I>PT</I><B>);</B>
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
The
<B>openproc</B>
function initializes a PROCTAB structure which can be used by iterated
readproc calls to get information on current processes. Depending on
<I>flags</I>,
openproc may need a second argument or a second and third argument
(see below).
<P>
<B>closeproc</B>
closes all files opened by
<B>openproc</B>
and deallocates the memory allocated by
<B>openproc.</B>
<P>
The PROCTAB structure is defined in
<I>&lt;<A HREF="file:///usr/include/proc/readproc.h">proc/readproc.h</A>&gt;</I>
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
<B>openproc</B>
returns a pointer to a PROCTAB structure, or NULL if an error
occurs. This usually means that
<I>/proc</I>
cannot be read by the process.
<P>
<A NAME="lbAF">&nbsp;</A>
<H2>FLAGS</H2>
<P>
The behaviour of
<B>openproc</B>
is controlled by the following set of flags, which may be ORed
together. There are three
different kinds of flags. The first group of flags determins which
information gets read from /proc/#pid for each process. The second
group of flags (of which only one can be enacted for a opendir call)
restricts which processes information is read for by providing a list
of criteria. The third group of flags restricts this as well, but
doesn't need arguments. These may be used together again.
<P>
<DL COMPACT>
<DT id="1"><B>PROC_FILLMEM</B>
<DD>
read information from
<I>/proc/#pid/statm</I>
<DT id="2"><B>PROC_FILLCOM</B>
<DD>
allocate
<I>cmdline</I>
part of
<I>proc_t</I>
and read information from
<I>/proc/#pid/cmdline</I>
<DT id="3"><B>PROC_FILLENV</B>
<DD>
allocate
<I>environ</I>
part of
<I>proc_t</I>
and read information from
<I>/proc/#pid/environ</I>
<DT id="4"><B>PROC_FILLUSR</B>
<DD>
resolve user ids to names via
<I>/etc/passwd</I>
<DT id="5"><B>PROC_FILLGRP</B>
<DD>
resolve group ids to names via
<I>/etc/group</I>
<DT id="6"><B>PROC_FILLSTATUS</B>
<DD>
read information from
<I>/proc/#pid/status</I>
<DT id="7"><B>PROC_FILLSTAT</B>
<DD>
read information from
<I>/proc/#pid/stat</I>
<DT id="8"><B>PROC_FILLARG</B>
<DD>
equivalent to PROC_FILLCOM
<DT id="9"><B>PROC_FILLCGROUP</B>
<DD>
alloc and fill in cgroup
<DT id="10"><B>PROC_FILLSUPGRP</B>
<DD>
resolve supplementary group id -&gt; group name
<DT id="11"><B>PROC_FILLOOM</B>
<DD>
fill in proc_t oom_score and oom_adj
<DT id="12"><B>PROC_FILLNS</B>
<DD>
fill in proc_t namespace information
<DT id="13"><B>PROC_FILLSYSTEMD</B>
<DD>
fill in proc_t systemd information
<DT id="14"><B>PROC_LOOSE_TASKS</B>
<DD>
threat threads as if they were processes
<DT id="15"><B>PROC_PID</B> (2nd argument pid_t*<B> </B><I>pidlist</I>)
<DD>
lookup only processes whose pid is contained in
<I>pidlist</I>
(the list is terminated with 0)
<DT id="16"><B>PROC_UID</B> (arguments uid_t*<B> </B><I>uidlist</I><B>, int </B><I>n</I>)
<DD>
lookup only processes whose user id is contained in
<I>uidlist</I>
(where
<I>n</I>
is the number of uids contained in the list)
<DT id="17"><B>PROC_EDITCGRPCVT</B>
<DD>
edit cgroup as single vector
<DT id="18"><B>PROC_EDITCMDLCVT</B>
<DD>
edit cmdline as single vector
<DT id="19"><B>PROC_EDITENVRCVT</B>
<DD>
edit environ as single vector
<P>
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>NOTE</H2>
Only one of the flags needing additional arguments
(<B>PROC_{PID,UID}</B>)
may be used at a time.
<P>
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?3+readproc">readproc</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+readproctab">readproctab</A></B>(3),
<B>/proc/</B>,
<B>/usr/include/proc/readproc.h</B>,
<A NAME="lbAI">&nbsp;</A>
<H2>REPORTING BUGS</H2>
Please send bug reports to
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="20"><A HREF="#lbAB">NAME</A><DD>
<DT id="21"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="22"><A HREF="#lbAD">SYNOPSIS</A><DD>
<DT id="23"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="24"><A HREF="#lbAF">FLAGS</A><DD>
<DT id="25"><A HREF="#lbAG">NOTE</A><DD>
<DT id="26"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="27"><A HREF="#lbAI">REPORTING BUGS</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:49 GMT, March 31, 2021
</BODY>
</HTML>