This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
One more FD_CLOEXEC case, missed in 131d45a9.
authorJarkko Hietaniemi <jhi@iki.fi>
Wed, 26 Aug 2015 23:57:08 +0000 (19:57 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 26 Aug 2015 23:58:01 +0000 (19:58 -0400)
doio.c

diff --git a/doio.c b/doio.c
index 1b1e951..d038986 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -771,12 +771,10 @@ S_openn_cleanup(pTHX_ GV *gv, IO *io, PerlIO *fp, char *mode, const char *oname,
        PerlIO_clearerr(fp);
        fd = PerlIO_fileno(fp);
     }
        PerlIO_clearerr(fp);
        fd = PerlIO_fileno(fp);
     }
-#if defined(HAS_FCNTL) && defined(F_SETFD)
-    if (fd >= 0) {
-        if (fcntl(fd, F_SETFD, fd > PL_maxsysfd) < 0) {
-            PerlLIO_close(fd);
-            goto say_false;
-        }
+#if defined(HAS_FCNTL) && defined(F_SETFD) && defined(FD_CLOEXEC)
+    if (fd > PL_maxsysfd && fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
+        PerlLIO_close(fd);
+        goto say_false;
     }
 #endif
     IoIFP(io) = fp;
     }
 #endif
     IoIFP(io) = fp;