aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2014-03-21 16:41:12 +0100
committerHenrik Nord <[email protected]>2014-03-21 16:41:12 +0100
commitc2b4eab25c907f453a394d382c04cd04e6c06b49 (patch)
tree74715cd85b536c1beaf5d4d13690aa7bc329863d /erts
parent0aa69369016b20ea6a02ecf0ab9b2ce7e05325b0 (diff)
parenta2820c8db97c05d4fc11e04048c123e1da24da88 (diff)
downloadotp-c2b4eab25c907f453a394d382c04cd04e6c06b49.tar.gz
otp-c2b4eab25c907f453a394d382c04cd04e6c06b49.tar.bz2
otp-c2b4eab25c907f453a394d382c04cd04e6c06b49.zip
Merge branch 'nox/reedr-closefrom'
* nox/reedr-closefrom: Use closefrom(2) when available in child_setup Conflicts: erts/emulator/sys/unix/erl_child_setup.c OTP-11809
Diffstat (limited to 'erts')
-rw-r--r--erts/configure.in2
-rw-r--r--erts/emulator/sys/unix/erl_child_setup.c7
2 files changed, 8 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 34d7f9e0e5..94eb6b1547 100644
--- a/erts/emulator/sys/unix/erl_child_setup.c
+++ b/erts/emulator/sys/unix/erl_child_setup.c
@@ -111,6 +111,13 @@ main(int argc, char *argv[])
(void) close(i);
#endif /* __ANDROID__ */
+#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)
return 1;