aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Reed <[email protected]>2012-12-13 10:13:53 -0800
committerAnthony Ramine <[email protected]>2014-03-09 12:32:56 +0100
commita2820c8db97c05d4fc11e04048c123e1da24da88 (patch)
tree8cc442f3da32818e3f0cee926576b3500d8248f8
parent870737ab657433c5e8751255fe3c4d298202d142 (diff)
downloadotp-a2820c8db97c05d4fc11e04048c123e1da24da88.tar.gz
otp-a2820c8db97c05d4fc11e04048c123e1da24da88.tar.bz2
otp-a2820c8db97c05d4fc11e04048c123e1da24da88.zip
Use closefrom(2) when available in child_setup
-rw-r--r--erts/configure.in2
-rw-r--r--erts/emulator/sys/unix/erl_child_setup.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/erts/configure.in b/erts/configure.in
index 074882532f..6d5eca8966 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -1151,7 +1151,7 @@ fi
AC_SUBST(ERTS_BUILD_SMP_EMU)
-AC_CHECK_FUNCS([posix_fadvise])
+AC_CHECK_FUNCS([posix_fadvise closefrom])
AC_CHECK_HEADERS([linux/falloc.h])
dnl * Old glibcs have broken fallocate64(). Make sure not to use it.
AC_CACHE_CHECK([whether fallocate() works],i_cv_fallocate_works,[
diff --git a/erts/emulator/sys/unix/erl_child_setup.c b/erts/emulator/sys/unix/erl_child_setup.c
index 7c6e4a2f37..99d2b2a739 100644
--- a/erts/emulator/sys/unix/erl_child_setup.c
+++ b/erts/emulator/sys/unix/erl_child_setup.c
@@ -89,8 +89,12 @@ main(int argc, char *argv[])
if (sscanf(argv[CS_ARGV_FD_CR_IX], "%d:%d", &from, &to) != 2)
return 1;
+#if defined(HAVE_CLOSEFROM)
+ closefrom(from);
+#else
for (i = from; i <= to; i++)
(void) close(i);
+#endif
if (!(argv[CS_ARGV_WD_IX][0] == '.' && argv[CS_ARGV_WD_IX][1] == '\0')
&& chdir(argv[CS_ARGV_WD_IX]) < 0)