PROC_WALK(3PROC) Process Control Library Functions PROC_WALK(3PROC)
NAME
proc_walk - walk all processes or threads in /proc
LIBRARY
Process Control Library (libproc, -lproc)
SYNOPSIS
#include <libproc.h> int proc_walk(
proc_walk_f *func,
void *arg,
int flag);
DESCRIPTION
The
proc_walk() function walks all threads and processes in /proc and
calls the callback function
func once for each one with the user
specified
arg. The definition of the
proc_walk_f is available in
libproc(3LIB).
func will be called once for each process and will always have its
first argument filled in with the value of the
psinfo file of the
process. The value of
flag controls whether or not information about
the threads in the process are included and how many times the callback
function
func is called. The following values may be passed in for
flag:
PR_WALK_PROC Indicates that the walker is only concerned with
the process.
func will be called once for each
process in the system. Only the
psinfo will be
read for the process and passed to
func. The
second argument, the one for the
lwpsinfo_t, will
be passed as NULL.
PR_WALK_LWP The caller wants both process and thread
information.
func will be called once for each
thread in the system. In addition to the process
psinfo information, the ps specific information for
a given thread will be included in the
lwpsinfo_t argument.
In addition, the following values may be combined with one of the above
values of
flag with a bitwise-inclusive-OR:
PR_WALK_INCLUDE_SYS
Include
SYS (system) processes. Normally
SYS processes are skipped during the walk of the
process tree.
The return value of the caller's
func function determines whether or
not iteration will continue. If
func returns a non-zero value, then
iteration will terminate and that return value will be returned to the
caller. To distinguish between system errors and caller errors, it is
recommended that the function only return positive integers in the
event of an error.
RETURN VALUES
Upon successful completion, the
proc_walk() function returns
0.
Otherwise,
-1 is returned and
errno is updated to reflect the error
that occurred.
ERRORS
In addition to the errors listed below, the
proc_walk() function may
fail for the same reasons as the
opendir(3C),
readdir(3C), and
malloc(3C) functions.
EINVAL
flag is not one of PR_WALK_PROC or PR_WALK_LWP.
INTERFACE STABILITY
UncommittedMT-LEVEL MT-SafeSEE ALSO
malloc(3C),
opendir(3C),
readdir(3C),
libproc(3LIB),
proc(5)illumos November 27, 2023 illumos