diff --git a/Makefile b/Makefile index e2c4d17a1..6c19d3dfe 100644 --- a/Makefile +++ b/Makefile @@ -374,6 +374,7 @@ ifeq ($(TARGET),freebsd) USE_LIBCRYPT = implicit USE_THREAD = implicit USE_CPU_AFFINITY= implicit + USE_CLOSEFROM = implicit else ifeq ($(TARGET),osx) # This is for Mac OS/X @@ -682,6 +683,10 @@ endif endif endif +ifneq ($(USE_CLOSEFROM),) +OPTIONS_CFLAGS += -DUSE_CLOSEFROM +endif + ifneq ($(USE_LUA),) check_lua_lib = $(shell echo "int main(){}" | $(CC) -o /dev/null -x c - $(2) -l$(1) 2>/dev/null && echo $(1)) check_lua_inc = $(shell if [ -d $(2)$(1) ]; then echo $(2)$(1); fi;) diff --git a/src/fd.c b/src/fd.c index 314e10fa2..581c5aaae 100644 --- a/src/fd.c +++ b/src/fd.c @@ -468,7 +468,13 @@ void fd_process_cached_events() fdlist_process_cached_events(&fd_cache); } -#if defined(ENABLE_POLL) +#if defined(USE_CLOSEFROM) +void my_closefrom(int start) +{ + closefrom(start); +} + +#elif defined(ENABLE_POLL) /* This is a portable implementation of closefrom(). It closes all open file * descriptors starting at and above. It relies on the fact that poll() * will return POLLNVAL for each invalid (hence close) file descriptor passed