PROC_FDWALK(3PROC) | Process Control Library Functions | PROC_FDWALK(3PROC) |
proc_fdwalk
— walk
the open file descriptors for a process
Process Control Library (libproc, -lproc)
#include
<libproc.h>
int
proc_fdwalk
(pid_t pid,
proc_fdwalk_f *func, void
*arg);
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.
Upon successful completion, the
proc_fdwalk
() 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_fdwalk
() function may fail for the same reasons
as the opendir(3C),
readdir(3C), and
malloc(3C) functions.
malloc(3C), opendir(3C), readdir(3C), libproc(3LIB), proc(5)
November 27, 2023 | OmniOS |