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] / perl.c
diff --git a/perl.c b/perl.c
index dabe45d..0c05c9a 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -4063,15 +4063,8 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, bool *suidscript)
                    CopFILE(PL_curcop), Strerror(errno));
     }
     fd = PerlIO_fileno(rsfp);
-#if defined(HAS_FCNTL) && defined(F_SETFD) && defined(FD_CLOEXEC)
-    if (fd >= 0) {
-        /* ensure close-on-exec */
-        if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
-            Perl_croak(aTHX_ "Can't open perl script \"%s\": %s\n",
-                       CopFILE(PL_curcop), Strerror(errno));
-        }
-    }
-#endif
+    if (fd >= 0)
+       setfd_cloexec(fd);
 
     if (fd < 0 ||
         (PerlLIO_fstat(fd, &tmpstatbuf) >= 0