Paul,

    Attached are two patches against make-3.80rc1 that I *must* apply to
    GNU make to get it work properly on PTX boxes.

    The first adds a new function, atomic_stat() which checks for and
    loops on EINTR.  The second adds EINTR handling to readdir() in dir.c.

    Both of these situations drove me nearly crazy when we starting really
    using GNU make here since it would work fine with one process, but
    die in various amusing ways with -j (since we get SIGCHLD).

    Please, please...could you add these patches or functionally equivalent
    code (if you don't like the patches themselves) to 3.80?

Michael Sterrett
  -Mr. Bones.-
[EMAIL PROTECTED]
diff -ur make-3.80rc1.orig/commands.c make-3.80rc1/commands.c
--- make-3.80rc1.orig/commands.c        Tue Jul  9 00:54:08 2002
+++ make-3.80rc1/commands.c     Mon Jul 15 15:34:30 2002
@@ -512,7 +512,7 @@
     }
 #endif
 
-  if (stat (file->name, &st) == 0
+  if (atomic_stat (file->name, &st) == 0
       && S_ISREG (st.st_mode)
       && FILE_TIMESTAMP_STAT_MODTIME (file->name, st) != file->last_mtime)
     {
diff -ur make-3.80rc1.orig/dir.c make-3.80rc1/dir.c
--- make-3.80rc1.orig/dir.c     Thu Jul 11 19:48:03 2002
+++ make-3.80rc1/dir.c  Mon Jul 15 15:34:00 2002
@@ -461,7 +461,7 @@
 #ifdef VMS
       r = vmsstat_dir (name, &st);
 #else
-      r = stat (name, &st);
+      r = atomic_stat (name, &st);
 #endif
 
 #ifdef WINDOWS32
@@ -1167,7 +1167,7 @@
 # ifndef VMS
 extern int stat ();
 # endif
-# define local_stat stat
+# define local_stat atomic_stat
 #else
 static int local_stat (path, buf)
     char *path;
diff -ur make-3.80rc1.orig/make.h make-3.80rc1/make.h
--- make-3.80rc1.orig/make.h    Thu Jul 11 19:48:03 2002
+++ make-3.80rc1/make.h Mon Jul 15 15:39:14 2002
@@ -455,6 +455,8 @@
 extern void make_access PARAMS ((void));
 extern void child_access PARAMS ((void));
 
+extern int atomic_stat (const char *, struct stat *);
+
 #ifdef  HAVE_VFORK_H
 # include <vfork.h>
 #endif
diff -ur make-3.80rc1.orig/misc.c make-3.80rc1/misc.c
--- make-3.80rc1.orig/misc.c    Thu Jul 11 19:48:03 2002
+++ make-3.80rc1/misc.c Mon Jul 15 15:40:10 2002
@@ -856,3 +856,14 @@
   return value;
 }
 #endif
+
+int
+atomic_stat (file_name, buf)
+const char *file_name;
+struct stat *buf;
+{
+  while (stat (file_name, buf) != 0)
+    if (errno != EINTR)
+      return -1;
+  return 0;
+}
diff -ur make-3.80rc1.orig/read.c make-3.80rc1/read.c
--- make-3.80rc1.orig/read.c    Thu Jul 11 19:48:03 2002
+++ make-3.80rc1/read.c Mon Jul 15 15:35:14 2002
@@ -2796,7 +2796,7 @@
              dir = expanded;
          }
 
-       if (stat (dir, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
+       if (atomic_stat (dir, &stbuf) == 0 && S_ISDIR (stbuf.st_mode))
          {
            if (idx == max - 1)
              {
@@ -2829,7 +2829,7 @@
 #endif
 
   for (i = 0; default_include_directories[i] != 0; ++i)
-    if (stat (default_include_directories[i], &stbuf) == 0
+    if (atomic_stat (default_include_directories[i], &stbuf) == 0
        && S_ISDIR (stbuf.st_mode))
       dirs[idx++] = default_include_directories[i];
 
diff -ur make-3.80rc1.orig/remake.c make-3.80rc1/remake.c
--- make-3.80rc1.orig/remake.c  Thu Jul 11 19:48:03 2002
+++ make-3.80rc1/remake.c       Mon Jul 15 15:35:49 2002
@@ -1266,7 +1266,7 @@
 {
   struct stat st;
 
-  if (stat (name, &st) != 0)
+  if (atomic_stat (name, &st) != 0)
     {
       if (errno != ENOENT && errno != ENOTDIR)
         perror_with_name ("stat:", name);
diff -ur make-3.80rc1.orig/vpath.c make-3.80rc1/vpath.c
--- make-3.80rc1.orig/vpath.c   Tue Jun 13 01:22:52 2000
+++ make-3.80rc1/vpath.c        Mon Jul 15 15:37:42 2002
@@ -515,7 +515,7 @@
 #endif
 
          if (!exists_in_cache  /* Makefile-mentioned file need not exist.  */
-             || stat (name, &st) == 0) /* Does it really exist?  */
+             || atomic_stat (name, &st) == 0) /* Does it really exist?  */
            {
              /* We have found a file.
                 Store the name we found into *FILE for the caller.  */
--- make-3.80rc1.orig/dir.c     Thu Jul 11 19:48:03 2002
+++ make-3.80rc1/dir.c  Mon Jul 15 15:52:13 2002
@@ -653,13 +653,19 @@
        return 0;
     }
 
-  while ((d = readdir (dir->dirstream)) != 0)
+  for(;;)
     {
       /* Enter the file in the hash table.  */
       unsigned int len;
       struct dirfile dirfile_key;
       struct dirfile **dirfile_slot;
 
+      errno = 0;
+      if ((d = readdir (dir->dirstream)) == 0) {
+       if (errno == EINTR)
+         continue;
+       break;
+      }
 #if defined(VMS) && defined(HAVE_DIRENT_H)
       /* In VMS we get file versions too, which have to be stripped off */
       {

Reply via email to