avoid looking up stale PL_statbuf (spotted by Charles Lane
Gurusamy Sarathy [Sat, 4 Mar 2000 19:02:27 +0000 (19:02 +0000)]
<lane@DUPHY4.Physics.Drexel.Edu>)

p4raw-id: //depot/perl@5524

doio.c

diff --git a/doio.c b/doio.c
index d0a7704..3cd199b 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -646,13 +646,17 @@ Perl_nextargv(pTHX_ register GV *gv)
        else {
            dTHR;
            if (ckWARN_d(WARN_INPLACE)) {
-               if (!S_ISREG(PL_statbuf.st_mode))       
+               int eno = errno;
+               if (PerlLIO_stat(PL_oldname, &PL_statbuf) >= 0
+                   && !S_ISREG(PL_statbuf.st_mode))    
+               {
                    Perl_warner(aTHX_ WARN_INPLACE,
                                "Can't do inplace edit: %s is not a regular file",
                                PL_oldname);
+               }
                else
                    Perl_warner(aTHX_ WARN_INPLACE, "Can't open %s: %s",
-                               PL_oldname, Strerror(errno));
+                               PL_oldname, Strerror(eno));
            }
        }
     }