This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
One paste too many in #2345.
[perl5.git] / doio.c
diff --git a/doio.c b/doio.c
index f624dca..c7c6455 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -366,8 +366,12 @@ do_open(GV *gv, register char *name, I32 len, int as_raw, int rawmode, int rawpe
        PerlIO_clearerr(fp);
     }
 #if defined(HAS_FCNTL) && defined(F_SETFD)
-    fd = PerlIO_fileno(fp);
-    fcntl(fd,F_SETFD,fd > PL_maxsysfd);
+    {
+       int save_errno = errno;
+       fd = PerlIO_fileno(fp);
+       fcntl(fd,F_SETFD,fd > PL_maxsysfd); /* can change errno */
+       errno = save_errno;
+    }
 #endif
     IoIFP(io) = fp;
     if (writing) {