mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Extend the code to effciently close unwanted file descriptors to *BSD.
This commit is contained in:
18
src/util.c
18
src/util.c
@@ -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.
|
||||||
|
|
||||||
|
On *BSD, the same facility is found at /dev/fd.
|
||||||
|
|
||||||
|
If this fails we drop back to the dumb code.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#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