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

iterate open files in a process

Process Control Library (libproc, -lproc)

#include <libproc.h>

Pfdinfo_iter(struct ps_prochandle *P, proc_fdinfo_f *func, void *data);

The Pfdinfo_iter() function iterates over the open files in the process represented by P.

For each open file, the callback function func will be invoked and it will be passed the data argument as well as a pointer to a prfdinfo_t structure defined in libproc(3LIB). For the full signature of the proc_fdinfo_f see libproc(3LIB).

The return value of func controls whether or not iteration continues. If func returns 0, then iteration will continue. However, if func instead returns a non-zero value, then iteration will halt and that value will be used as the return value of the Pfdinfo_iter() function. Because the Pfdinfo_iter() function returns -1 to an indicate its own errors, it is recommended that the callback function does not return -1 to indicate an error so that the caller may distinguish between the failure of the callback function and the failure of the Pfdinfo_iter() function.

Upon successful completion, the Pfdinfo_iter() returns 0. Otherwise, if there was an internal error then -1 is returned. Otherwise, if the callback function func returns non-zero, then its return value will be returned instead.


See LOCKING in libproc(3LIB).

May 11, 2016 OmniOS