From 1b9024889384fc26d296ee4340ffca32e8c73017 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 15 Sep 2013 16:41:42 -0400 Subject: [SV 27374] Fatal immediately on unrecoverable fopen() errors. --- read.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'read.c') 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. */ -- cgit v1.2.3