Date: Wed, 31 May 2000 14:22:39 -0400 (EDT)
   From: "Paul D. Smith" <[EMAIL PROTECTED]>

   Two solutions immediately present themselves:

    1) Just wrap stat(2) in a loop checking for EINTR, even though that's
       not possible on any standard UNIX system.

Actually, EINTR is possible on a POSIX-compliant system, since POSIX
allows (but does not require) stat to fail with EINTR.  Wrapping stat
is the right fix, I think.

Also, while we're on the subject, that code should check for other
failures.  For example, if the file can't be stat'ed because the
parent directory is unreadable, an error should be reported.

Here's a proposed patch.


2000-05-31  Paul Eggert  <[EMAIL PROTECTED]>

        * remake.c (name_mtime): Check for stat failures.
        Retry if EINTR.

===================================================================
RCS file: remake.c,v
retrieving revision 3.79.0.2
retrieving revision 3.79.0.3
diff -pu -r3.79.0.2 -r3.79.0.3
--- remake.c    2000/05/22 16:45:52     3.79.0.2
+++ remake.c    2000/05/31 21:25:10     3.79.0.3
@@ -1216,8 +1216,13 @@ name_mtime (name)
 {
   struct stat st;
 
-  if (stat (name, &st) < 0)
-    return (FILE_TIMESTAMP) -1;
+  while (stat (name, &st) != 0)
+    if (errno != EINTR)
+      {
+       if (errno != ENOENT && errno != ENOTDIR)
+         perror_with_name ("stat:", name);
+       return (FILE_TIMESTAMP) -1;
+      }
 
   return FILE_TIMESTAMP_STAT_MODTIME (st);
 }

Reply via email to