1a02120c4SAndy Fiddaman.\" 2a02120c4SAndy Fiddaman.\" This file and its contents are supplied under the terms of the 3a02120c4SAndy Fiddaman.\" Common Development and Distribution License ("CDDL"), version 1.0. 4a02120c4SAndy Fiddaman.\" You may only use this file in accordance with the terms of version 5a02120c4SAndy Fiddaman.\" 1.0 of the CDDL. 6a02120c4SAndy Fiddaman.\" 7a02120c4SAndy Fiddaman.\" A full copy of the text of the CDDL should have accompanied this 8a02120c4SAndy Fiddaman.\" source. A copy of the CDDL is also available via the Internet at 9a02120c4SAndy Fiddaman.\" http://www.illumos.org/license/CDDL. 10a02120c4SAndy Fiddaman.\" 11a02120c4SAndy Fiddaman.\" 12a02120c4SAndy Fiddaman.\" Copyright 2020 OmniOS Community Edition (OmniOSce) Association. 13a02120c4SAndy Fiddaman.\" 14*a7d7cafeSRobert Mustacchi.Dd November 27, 2023 15a02120c4SAndy Fiddaman.Dt PROC_FDWALK 3PROC 16a02120c4SAndy Fiddaman.Os 17a02120c4SAndy Fiddaman.Sh NAME 18a02120c4SAndy Fiddaman.Nm proc_fdwalk 19a02120c4SAndy Fiddaman.Nd walk the open file descriptors for a process 20*a7d7cafeSRobert Mustacchi.Sh LIBRARY 21a02120c4SAndy Fiddaman.Lb libproc 22*a7d7cafeSRobert Mustacchi.Sh SYNOPSIS 23a02120c4SAndy Fiddaman.In libproc.h 24a02120c4SAndy Fiddaman.Ft int 25a02120c4SAndy Fiddaman.Fo proc_fdwalk 26a02120c4SAndy Fiddaman.Fa "pid_t pid" 27a02120c4SAndy Fiddaman.Fa "proc_fdwalk_f *func" 28a02120c4SAndy Fiddaman.Fa "void *arg" 29a02120c4SAndy Fiddaman.Fc 30a02120c4SAndy Fiddaman.Sh DESCRIPTION 31a02120c4SAndy FiddamanThe 32a02120c4SAndy Fiddaman.Fn proc_fdwalk 33a02120c4SAndy Fiddamanfunction walks all file descriptors currently open in the process with ID 34a02120c4SAndy Fiddaman.Fa pid 35a02120c4SAndy Fiddamanand calls the callback function 36a02120c4SAndy Fiddaman.Fa func 37a02120c4SAndy Fiddamanonce for each file descriptor with the user-specified 38a02120c4SAndy Fiddaman.Fa arg . 39a02120c4SAndy FiddamanThe definition of 40a02120c4SAndy Fiddaman.Vt proc_fdwalk_f 41a02120c4SAndy Fiddamanis available in 42a02120c4SAndy Fiddaman.Xr libproc 3LIB . 43a02120c4SAndy Fiddaman.Pp 44a02120c4SAndy Fiddaman.Fa func 45a02120c4SAndy Fiddamanwill be called once for each file descriptor and will have its first 46a02120c4SAndy Fiddamanargument filled in with the contents of the corresponding 47a02120c4SAndy Fiddaman.Pa /proc 48a02120c4SAndy Fiddaman.Sy fdinfo 49a02120c4SAndy Fiddamanfile for the file descriptor. 50a02120c4SAndy Fiddaman.Pp 51a02120c4SAndy FiddamanThe return value of the caller's 52a02120c4SAndy Fiddaman.Fa func 53a02120c4SAndy Fiddamanfunction determines whether or not iteration will continue. 54a02120c4SAndy FiddamanIf 55a02120c4SAndy Fiddaman.Fa func 56a02120c4SAndy Fiddamanreturns a non-zero value, then iteration will terminate and that 57a02120c4SAndy Fiddamanreturn value will be returned to the caller. 58a02120c4SAndy FiddamanTo distinguish between system errors and caller errors, it is recommended that 59a02120c4SAndy Fiddamanthe function only return positive integers in the event of an error. 60a02120c4SAndy Fiddaman.Sh RETURN VALUES 61a02120c4SAndy FiddamanUpon successful completion, the 62a02120c4SAndy Fiddaman.Fn proc_fdwalk 63a02120c4SAndy Fiddamanfunction returns 64a02120c4SAndy Fiddaman.Sy 0 . 65a02120c4SAndy FiddamanOtherwise, 66a02120c4SAndy Fiddaman.Sy -1 67a02120c4SAndy Fiddamanis returned and 68a02120c4SAndy Fiddaman.Sy errno 69a02120c4SAndy Fiddamanis updated to reflect the error that occurred. 70a02120c4SAndy Fiddaman.Sh ERRORS 71a02120c4SAndy FiddamanIn addition to the errors listed below, the 72a02120c4SAndy Fiddaman.Fn proc_fdwalk 73a02120c4SAndy Fiddamanfunction may fail for the same reasons as the 74a02120c4SAndy Fiddaman.Xr opendir 3C , 75a02120c4SAndy Fiddaman.Xr readdir 3C , 76a02120c4SAndy Fiddamanand 77a02120c4SAndy Fiddaman.Xr malloc 3C 78a02120c4SAndy Fiddamanfunctions. 79a02120c4SAndy Fiddaman.Sh INTERFACE STABILITY 80a02120c4SAndy Fiddaman.Sy Uncommitted 81a02120c4SAndy Fiddaman.Sh MT-LEVEL 82a02120c4SAndy Fiddaman.Sy MT-Safe 83a02120c4SAndy Fiddaman.Sh SEE ALSO 84a02120c4SAndy Fiddaman.Xr malloc 3C , 85a02120c4SAndy Fiddaman.Xr opendir 3C , 86a02120c4SAndy Fiddaman.Xr readdir 3C , 87a02120c4SAndy Fiddaman.Xr libproc 3LIB , 88bbf21555SRichard Lowe.Xr proc 5 89