Use ENULLLOOP to handle EINTR during realpath(). Fixes Savannah bug #38420
authorPaul Smith <psmith@gnu.org>
Thu, 28 Feb 2013 05:55:15 +0000 (00:55 -0500)
committerPaul Smith <psmith@gnu.org>
Thu, 28 Feb 2013 05:55:15 +0000 (00:55 -0500)
ChangeLog
dep.h
function.c
loadapi.c

index 9918dc6b13c0efff59ba3af98a496c3899d53128..8dc920a4cb835bda2239db0a55ec048ed57c29be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-02-28  Paul Smith  <psmith@gnu.org>
+
+       * function.c (func_realpath): On Solaris (at least) realpath() can
+       fail due to EINTR, so loop it.  Fixes Savannah bug #38420.
+
 2013-02-25  Paul Smith  <psmith@gnu.org>
 
        Add a proposed supported API for GNU make loaded objects.
diff --git a/dep.h b/dep.h
index 1a50e255db31901ac5ec519c33f56f1c86ff5135..3eab961b709a33c2dd54dff871c8868a97fa7cbf 100644 (file)
--- a/dep.h
+++ b/dep.h
@@ -87,4 +87,5 @@ struct dep *copy_dep_chain (const struct dep *d);
 void free_dep_chain (struct dep *d);
 void free_ns_chain (struct nameseq *n);
 struct dep *read_all_makefiles (const char **makefiles);
+void eval_buffer (char *buffer, const gmk_floc *floc);
 int update_goal_chain (struct dep *goals);
index b6060d6f54ad38ab845274d6b1fc8634f5888f8a..1242d9abf2e2fbed36acb0a606f8145af8af0756 100644 (file)
@@ -2070,28 +2070,35 @@ func_realpath (char *o, char **argv, const char *funcname UNUSED)
   const char *path = 0;
   int doneany = 0;
   unsigned int len = 0;
-  struct stat st;
-  PATH_VAR (in);
-  PATH_VAR (out);
 
   while ((path = find_next_token (&p, &len)) != 0)
     {
       if (len < GET_PATH_MAX)
         {
+          char *rp;
+          struct stat st;
+          PATH_VAR (in);
+          PATH_VAR (out);
+
           strncpy (in, path, len);
           in[len] = '\0';
 
-          if (
 #ifdef HAVE_REALPATH
-              realpath (in, out)
+          ENULLLOOP (rp, realpath (in, out));
 #else
-              abspath (in, out)
+          rp = abspath (in, out);
 #endif
-              && stat (out, &st) == 0)
+
+          if (rp)
             {
-              o = variable_buffer_output (o, out, strlen (out));
-              o = variable_buffer_output (o, " ", 1);
-              doneany = 1;
+              int r;
+              EINTRLOOP (r, stat (out, &st));
+              if (r == 0)
+                {
+                  o = variable_buffer_output (o, out, strlen (out));
+                  o = variable_buffer_output (o, " ", 1);
+                  doneany = 1;
+                }
             }
         }
     }
@@ -2150,13 +2157,14 @@ func_abspath (char *o, char **argv, const char *funcname UNUSED)
   const char *path = 0;
   int doneany = 0;
   unsigned int len = 0;
-  PATH_VAR (in);
-  PATH_VAR (out);
 
   while ((path = find_next_token (&p, &len)) != 0)
     {
       if (len < GET_PATH_MAX)
         {
+          PATH_VAR (in);
+          PATH_VAR (out);
+
           strncpy (in, path, len);
           in[len] = '\0';
 
@@ -2191,7 +2199,7 @@ func_abspath (char *o, char **argv, const char *funcname UNUSED)
 static char *func_call (char *o, char **argv, const char *funcname);
 
 #define FT_ENTRY(_name, _min, _max, _exp, _func) \
-  { (_func), STRING_SIZE_TUPLE(_name), (_min), (_max), (_exp), 0 }
+  { { (_func) }, STRING_SIZE_TUPLE(_name), (_min), (_max), (_exp), 0 }
 
 static struct function_table_entry function_table_init[] =
 {
index 3170dd1218dbb01b7d561dd6a2823e3125fd04b5..f2823e1d90ca1bc875178ba667c3ac44392ee81e 100644 (file)
--- a/loadapi.c
+++ b/loadapi.c
@@ -20,6 +20,7 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "filedef.h"
 #include "variable.h"
+#include "dep.h"
 
 /* Evaluate a buffer as make syntax.
    Ideally eval_buffer() will take const char *, but not yet.  */