PROC_FDWALK(3PROC) Process Control Library Functions PROC_FDWALK(3PROC)
NAME
proc_fdwalk - walk the open file descriptors for a process
LIBRARY
Process Control Library (libproc, -lproc)
SYNOPSIS
#include <libproc.h> int proc_fdwalk(
pid_t pid,
proc_fdwalk_f *func,
void *arg);
DESCRIPTION
The
proc_fdwalk() function walks all file descriptors currently open in the
process with ID
pid and calls the callback function
func once for each file
descriptor with the user-specified
arg. The definition of
proc_fdwalk_f is
available in
libproc(3LIB).
func will be called once for each file descriptor and will have its first
argument filled in with the contents of the corresponding
/proc fdinfo file
for the file descriptor.
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_fdwalk() 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_fdwalk() function may fail
for the same reasons as the
opendir(3C),
readdir(3C), and
malloc(3C) functions.
INTERFACE STABILITY
UncommittedMT-LEVEL MT-SafeSEE ALSO
malloc(3C),
opendir(3C),
readdir(3C),
libproc(3LIB),
proc(5)illumos November 27, 2023 illumos