Integrate from perlio:
Jarkko Hietaniemi [Sun, 18 May 2003 07:57:23 +0000 (07:57 +0000)]
[ 19542]
Fix ticket #22219

[ 19543]
Spotted a bare close() where PerlLIO_close() seems correct.
p4raw-link: @19543 on //depot/perlio: 8a521f284323c7ef06cccf453146cc13958cfd6d
p4raw-link: @19542 on //depot/perlio: 6a93df2e699ee31021f3373dcafbb41d67f7f951

p4raw-id: //depot/perl@19552
p4raw-integrated: from //depot/perlio@19550 'copy in' doio.c (@19473..)
perlio.c (@19538..)

doio.c
perlio.c

diff --git a/doio.c b/doio.c
index 43c12e7..1135a62 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -641,8 +641,16 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
                 /* need to close fp without closing underlying fd */
                 int ofd = PerlIO_fileno(fp);
                 int dupfd = PerlLIO_dup(ofd);
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+               /* Assume if we have F_SETFD we have F_GETFD */
+                int coe = fcntl(ofd,F_GETFD);
+#endif
                 PerlIO_close(fp);
                 PerlLIO_dup2(dupfd,ofd);
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+               /* The dup trick has lost close-on-exec on ofd */
+               fcntl(ofd,F_SETFD, coe);
+#endif
                 PerlLIO_close(dupfd);
            }
             else
index e0cb501..cab4243 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -432,7 +432,7 @@ PerlIO_findFILE(PerlIO *pio)
 
 /*
  * Why is this here - not in perlio.h?  RMB
- */ 
+ */
 void PerlIO_debug(const char *fmt, ...)
 #ifdef CHECK_FORMAT
     __attribute__ ((__format__(__printf__, 1, 2)))
@@ -2946,7 +2946,7 @@ PerlIOStdio_close(pTHX_ PerlIO *f)
        }
        if (dupfd) {
            PerlLIO_dup2(dupfd,fd);
-           close(dupfd);
+           PerlLIO_close(dupfd);
        }
        return result;
     }