PROC_WALK(3PROC) Process Control Library Functions PROC_WALK(3PROC)

proc_walkwalk 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 () 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 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:

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 , will be passed as NULL.
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:

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.

Upon successful completion, the proc_walk() function returns . Otherwise, is returned and 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.

flag is not one of PR_WALK_PROC or PR_WALK_LWP.

malloc(3C), opendir(3C), readdir(3C), libproc(3LIB), proc(5)

November 27, 2023 OmniOS