From d33ff301454fa1db9919674dbc2a37309bbd529f Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Thu, 30 Jan 2003 05:22:52 +0000 Subject: Portability fix for glob.h building in FreeBSD ports system. Implement a fix for bug # 2169: too many OSs, even major OSs like Solaris, don't properly implement SA_RESTART: important system calls like stat() can still fail when SA_RESTART is set. So, forget the BROKEN_RESTART config check and get rid of atomic_stat() and atomic_readdir(), and implement permanent wrappers for EINTR checking on various system calls (stat(), fstat(), opendir(), and readdir() so far). --- vpath.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'vpath.c') diff --git a/vpath.c b/vpath.c index 18aaaa9..5e04d08 100644 --- a/vpath.c +++ b/vpath.c @@ -507,27 +507,33 @@ selective_vpath_search (struct vpath *path, char **file, *n = '/'; #endif - if (!exists_in_cache /* Makefile-mentioned file need not exist. */ - || stat (name, &st) == 0) /* Does it really exist? */ + if (exists_in_cache) /* Makefile-mentioned file need not exist. */ { - /* We have found a file. - Store the name we found into *FILE for the caller. */ - - *file = savestring (name, (n + 1 - name) + flen); - - if (mtime_ptr != 0) - /* Store the modtime into *MTIME_PTR for the caller. - If we have had no need to stat the file here, - we record UNKNOWN_MTIME to indicate this. */ - *mtime_ptr = (exists_in_cache - ? FILE_TIMESTAMP_STAT_MODTIME (name, st) - : UNKNOWN_MTIME); - - free (name); - return 1; - } - else - exists = 0; + int e; + + EINTRLOOP (e, stat (name, &st)); /* Does it really exist? */ + if (e != 0) + { + exists = 0; + continue; + } + } + + /* We have found a file. + Store the name we found into *FILE for the caller. */ + + *file = savestring (name, (n + 1 - name) + flen); + + if (mtime_ptr != 0) + /* Store the modtime into *MTIME_PTR for the caller. + If we have had no need to stat the file here, + we record UNKNOWN_MTIME to indicate this. */ + *mtime_ptr = (exists_in_cache + ? FILE_TIMESTAMP_STAT_MODTIME (name, st) + : UNKNOWN_MTIME); + + free (name); + return 1; } } -- cgit v1.2.3