/* 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
/*
* Why is this here - not in perlio.h? RMB
- */
+ */
void PerlIO_debug(const char *fmt, ...)
#ifdef CHECK_FORMAT
__attribute__ ((__format__(__printf__, 1, 2)))
}
if (dupfd) {
PerlLIO_dup2(dupfd,fd);
- close(dupfd);
+ PerlLIO_close(dupfd);
}
return result;
}