summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-09-15 16:41:42 -0400
committerPaul Smith <psmith@gnu.org>2013-09-15 17:09:01 -0400
commit1b9024889384fc26d296ee4340ffca32e8c73017 (patch)
tree88312b516ca64a727dffcbe87bf9aec3674e7a92 /read.c
parenta4d8444b594e53b13659a9f2c64424418f255e27 (diff)
downloadgunmake-1b9024889384fc26d296ee4340ffca32e8c73017.tar.gz
[SV 27374] Fatal immediately on unrecoverable fopen() errors.
Diffstat (limited to 'read.c')
-rw-r--r--read.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/read.c b/read.c
index 834c7f8..f8542b0 100644
--- a/read.c
+++ b/read.c
@@ -353,10 +353,24 @@ eval_makefile (const char *filename, int flags)
filename = expanded;
}
- ebuf.fp = fopen (filename, "r");
+ ENULLLOOP (ebuf.fp, fopen (filename, "r"));
+
/* Save the error code so we print the right message later. */
makefile_errno = errno;
+ /* Check for unrecoverable errors: out of mem or FILE slots. */
+ switch (makefile_errno)
+ {
+#ifdef EMFILE
+ case EMFILE:
+#endif
+#ifdef ENFILE
+ case ENFILE:
+#endif
+ case ENOMEM:
+ fatal (reading_file, "%s", strerror (makefile_errno));
+ }
+
/* If the makefile wasn't found and it's either a makefile from
the 'MAKEFILES' variable or an included makefile,
search the included makefile search path for this makefile. */