This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
factor out remaining fcntl F_SETFD calls
[perl5.git] / doio.c
diff --git a/doio.c b/doio.c
index 160adc5..56615cd 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1014,12 +1014,10 @@ S_openn_cleanup(pTHX_ GV *gv, IO *io, PerlIO *fp, char *mode, const char *oname,
        PerlIO_clearerr(fp);
        fd = PerlIO_fileno(fp);
     }
-#if defined(HAS_FCNTL) && defined(F_SETFD) && defined(FD_CLOEXEC)
-    if (fd >= 0 && fd > PL_maxsysfd && fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
-        PerlLIO_close(fd);
-        goto say_false;
+    if (fd >= 0) {
+       setfd_cloexec(fd);
+       setfd_inhexec_for_sysfd(fd);
     }
-#endif
     IoIFP(io) = fp;
 
     IoFLAGS(io) &= ~IOf_NOLINE;