This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #24521] make test breaks permissions on /dev/tty
authorDave Mitchell <davem@fdisolutions.com>
Sun, 29 Feb 2004 18:06:45 +0000 (18:06 +0000)
committerDave Mitchell <davem@fdisolutions.com>
Sun, 29 Feb 2004 18:06:45 +0000 (18:06 +0000)
 perl -i could fchmod(stdin) by mistake

p4raw-id: //depot/perl@22415

doio.c

diff --git a/doio.c b/doio.c
index f0b036a..7e13f1f 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -723,11 +723,13 @@ Perl_nextargv(pTHX_ register GV *gv)
     if (PL_filemode & (S_ISUID|S_ISGID)) {
        PerlIO_flush(IoIFP(GvIOn(PL_argvoutgv)));  /* chmod must follow last write */
 #ifdef HAS_FCHMOD
-       (void)fchmod(PL_lastfd,PL_filemode);
+       if (PL_lastfd != -1)
+           (void)fchmod(PL_lastfd,PL_filemode);
 #else
        (void)PerlLIO_chmod(PL_oldname,PL_filemode);
 #endif
     }
+    PL_lastfd = -1;
     PL_filemode = 0;
     if (!GvAV(gv))
         return Nullfp;