diff --git a/ChangeLog b/ChangeLog index 9e3f5806af..cfea8f3132 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Oct 30 08:29:51 2011 Tanaka Akira + + * io.c (rb_cloexec_dup2): don't set CLOEXEC for standard file + descriptors. + Sun Oct 30 07:47:10 2011 Tanaka Akira * configure.in: check dup3. diff --git a/io.c b/io.c index 5bec3622f4..1e04a1d6f5 100644 --- a/io.c +++ b/io.c @@ -234,7 +234,7 @@ rb_cloexec_dup2(int oldfd, int newfd) #if defined(HAVE_DUP3) && defined(O_CLOEXEC) static int try_dup3 = 1; - if (try_dup3) { + if (2 < newfd && try_dup3) { ret = dup3(oldfd, newfd, O_CLOEXEC); /* dup3 is available since Linux 2.6.27. */ if (ret == -1 && errno == ENOSYS) {