Fix ticket #22219
authorNick Ing-Simmons <nik@tiuk.ti.com>
Sat, 17 May 2003 13:36:28 +0000 (13:36 +0000)
committerNick Ing-Simmons <nik@tiuk.ti.com>
Sat, 17 May 2003 13:36:28 +0000 (13:36 +0000)
p4raw-id: //depot/perlio@19542

doio.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