From 4d7f1e1864983c9ffc76a52af3346777806767ee Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 14 Jun 2012 01:19:56 +0200 Subject: [PATCH] unix: implement uv_disable_stdio_inheritance() --- src/unix/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/unix/core.c b/src/unix/core.c index b1d47ed0..524ffd0c 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -587,6 +587,14 @@ uv_err_t uv_chdir(const char* dir) { void uv_disable_stdio_inheritance(void) { + int fd; + + /* Set the CLOEXEC flag on all open descriptors. Unconditionally try the + * first 16 file descriptors. After that, bail out after the first error. + */ + for (fd = 0; ; fd++) + if (uv__cloexec(fd, 1) && fd > 15) + break; }