PROC_WALK(3PROC) | Process Control Library Functions | PROC_WALK(3PROC) |
proc_walk
— walk
all processes or threads in /proc
Process Control Library (libproc, -lproc)
#include
<libproc.h>
int
proc_walk
(proc_walk_f *func,
void *arg, int flag);
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
NULL
.PR_WALK_LWP
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
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.
Upon successful completion, the
proc_walk
() function returns
0. Otherwise,
-1 is returned
and
errno is
updated to reflect the error that occurred.
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
PR_WALK_PROC
or
PR_WALK_LWP
.malloc(3C), opendir(3C), readdir(3C), libproc(3LIB), proc(5)
November 27, 2023 | OmniOS |