I noticed that I forgot to remove a couple lines of debugging code from this patch. I've attached the fixed version. A little explaination also: This patch addes a function to misc.c called atomic_stat(). This function takes the same arguments as the normal stat() call, but loops and checks for EINTR. The function is then used in place of stat() thoughout the code. I got tired of wondering if certain stat() calls could fail. Some of them are before gmake would have forked so they might never get EINTR, but it's easier just to replace them rather than trace the program flow. Michael Sterrett -Mr. Bones.- [EMAIL PROTECTED]
diff -u commands.c commands.c --- commands.c Tue Jun 13 10:24:43 2000 +++ commands.c Mon Mar 12 16:49:22 2001 @@ -493,7 +493,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 -u dir.c dir.c --- dir.c Mon May 8 14:26:00 2000 +++ dir.c Mon Mar 12 16:49:23 2001 @@ -344,7 +344,7 @@ #ifdef VMS r = vmsstat_dir (name, &st); #else - r = stat (name, &st); + r = atomic_stat (name, &st); #endif #ifdef WINDOWS32 @@ -540,7 +540,7 @@ */ if (dir->path_key && (dir->fs_flags & FS_FAT || - (stat(dir->path_key, &st) == 0 && + (atomic_stat(dir->path_key, &st) == 0 && st.st_mtime > dir->mtime))) { /* reset date stamp to show most recent re-process */ @@ -1106,7 +1106,7 @@ char *path; struct stat *buf; { - return stat (path, buf); + return atomic_stat (path, buf); } #endif diff -u make.h make.h --- make.h Thu Jun 15 01:25:37 2000 +++ make.h Mon Mar 12 16:49:24 2001 @@ -466,6 +466,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 -u misc.c misc.c --- misc.c Tue Jun 20 10:00:17 2000 +++ misc.c Mon Mar 12 16:50:09 2001 @@ -857,3 +857,13 @@ 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 errno; +} diff -u read.c read.c --- read.c Wed Jun 21 15:33:30 2000 +++ read.c Mon Mar 12 16:49:30 2001 @@ -2464,7 +2464,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) { @@ -2497,7 +2497,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 -u remake.c remake.c --- remake.c Tue Jun 20 10:00:17 2000 +++ remake.c Mon Mar 12 16:49:32 2001 @@ -1228,13 +1228,12 @@ { struct stat st; - while (stat (name, &st) != 0) - if (errno != EINTR) - { - if (errno != ENOENT && errno != ENOTDIR) - perror_with_name ("stat:", name); - return NONEXISTENT_MTIME; - } + if (atomic_stat (name, &st) != 0) + { + if (errno != ENOENT && errno != ENOTDIR) + perror_with_name ("stat:", name); + return NONEXISTENT_MTIME; + } return FILE_TIMESTAMP_STAT_MODTIME (name, st); } diff -u vmsfunctions.c vmsfunctions.c --- vmsfunctions.c Sat Feb 5 02:50:48 2000 +++ vmsfunctions.c Mon Mar 12 16:49:33 2001 @@ -215,7 +215,7 @@ if (!(status & 1)) return -1; - status = stat (name, buf); + status = atomic_stat (name, buf); if (status) return -1; diff -u vpath.c vpath.c --- vpath.c Tue Jun 13 10:24:45 2000 +++ vpath.c Mon Mar 12 16:49:35 2001 @@ -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. */