From: Alan T. DeKok Date: Mon, 26 Sep 2016 14:54:33 +0000 (-0400) Subject: Add checks for Linux && OSX X-Git-Tag: release_3_0_12~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b364b57da0411fb0918cb000b56def852ae38895;p=thirdparty%2Ffreeradius-server.git Add checks for Linux && OSX --- diff --git a/src/lib/misc.c b/src/lib/misc.c index f81289bc228..50b12a4bc2e 100644 --- a/src/lib/misc.c +++ b/src/lib/misc.c @@ -31,22 +31,26 @@ RCSID("$Id$") #include #include +#ifdef HAVE_DIRENT_H +#include + /* * Some versions of Linux don't have closefrom(), but they will * have /proc. * * BSD systems will generally have closefrom(), but not proc. * - * If a system doesn't have closefrom() and isn't Linux, it - * doesn't have /proc, either. So don't waste time trying - * to open /proc. + * OSX doesn't have closefrom() or /proc/self/fd, but it does + * have /dev/fd */ -#ifdef HAVE_DIRENT_H #ifdef __linux__ -#include +#define CLOSEFROM_DIR "/proc/self/fd" +#elif defined(__APPLE__) +#define CLOSEFROM_DIR "/dev/fd" #else #undef HAVE_DIRENT_H #endif + #endif #define FR_PUT_LE16(a, val)\ @@ -1403,7 +1407,7 @@ int closefrom(int fd) /* * Use /proc/self/fd directory if it exists. */ - dir = opendir("/proc/self/fd"); + dir = opendir(CLOSEFROM_DIR); if (dir != NULL) { long my_fd; char *endp;