This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for ithreads/stdio build
[perl5.git] / perlio.c
index dd9f394..963601a 100644 (file)
--- a/perlio.c
+++ b/perlio.c
@@ -128,6 +128,24 @@ PerlIO_binmode(pTHX_ PerlIO *fp, int iotype, int mode, const char *names)
 #endif
 }
 
+PerlIO *
+PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param)
+{
+    if (f) {
+       int fd = PerlLIO_dup(PerlIO_fileno(f));
+       if (fd >= 0) {
+           /* the r+ is a hack */
+           return PerlIO_fdopen(fd, "r+");
+       }
+       return NULL;
+    }
+    else {
+       SETERRNO(EBADF, SS$_IVCHAN);
+    }
+    return NULL;
+}
+
+
 /*
  * De-mux PerlIO_openn() into fdopen, freopen and fopen type entries
  */