mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-12 16:50:54 +00:00
Extend the code to effciently close unwanted file descriptors to *BSD.
This commit is contained in:
1 file changed
+17
-3
+17
-3
@@ -810,11 +810,25 @@ void close_fds(long max_fd, int spare1, int spare2, int spare3)
|
|||||||
{
|
{
|
||||||
/* On Linux, use the /proc/ filesystem to find which files
|
/* On Linux, use the /proc/ filesystem to find which files
|
||||||
are actually open, rather than iterate over the whole space,
|
are actually open, rather than iterate over the whole space,
|
||||||
for efficiency reasons. If this fails we drop back to the dumb code. */
|
for efficiency reasons.
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
|
||||||
|
On *BSD, the same facility is found at /dev/fd.
|
||||||
|
|
||||||
|
If this fails we drop back to the dumb code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
|
#define FDESCFS "/proc/self/fd"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BSD_NETWORK
|
||||||
|
#define FDESCFS "/dev/fd"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FDESCFS
|
||||||
DIR *d;
|
DIR *d;
|
||||||
|
|
||||||
if ((d = opendir("/proc/self/fd")))
|
if ((d = opendir(FDESCFS)))
|
||||||
{
|
{
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user