1 /* 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef WEBRTC_BASE_LINUXFDWALK_H_ 12 #define WEBRTC_BASE_LINUXFDWALK_H_ 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 // Linux port of SunOS's fdwalk(3) call. It loops over all open file descriptors 19 // and calls func on each one. Additionally, it is safe to use from the child 20 // of a fork that hasn't exec'ed yet, so you can use it to close all open file 21 // descriptors prior to exec'ing a daemon. 22 // The return value is 0 if successful, or else -1 and errno is set. The 23 // possible errors include any error that can be returned by opendir(), 24 // readdir(), or closedir(), plus EBADF if there are problems parsing the 25 // contents of /proc/self/fd. 26 // The file descriptors that are enumerated will not include the file descriptor 27 // used for the enumeration itself. 28 int fdwalk(void (*func)(void *, int), void *opaque); 29 30 #ifdef __cplusplus 31 } // extern "C" 32 #endif 33 34 #endif // WEBRTC_BASE_LINUXFDWALK_H_ 35