summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-11-26 06:29:06 -0700
committerEric Blake <ebb9@byu.net>2009-11-26 06:29:06 -0700
commit30cd2068dcb8b51f9fe29741732027bb00b522a5 (patch)
tree976817d1dc5659a965ee18b2c70c543b77ce7d75
parent324f56e49ed43de04cf6e648fea9d89739788f24 (diff)
downloadm4-30cd2068dcb8b51f9fe29741732027bb00b522a5.tar.gz
Ignore write failures before stack overflow exit.
* m4/gnulib-cache.m4: Import ignore-value module. * src/m4.c (fault_handler): Use it to avoid compiler warning. Signed-off-by: Eric Blake <ebb9@byu.net>
-rw-r--r--ChangeLog6
-rw-r--r--m4/gnulib-cache.m43
-rw-r--r--src/m4.c18
3 files changed, 19 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b4cc72a..19cf20d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-26 Eric Blake <ebb9@byu.net>
+
+ Ignore write failures before stack overflow exit.
+ * m4/gnulib-cache.m4: Import ignore-value module.
+ * src/m4.c (fault_handler): Use it to avoid compiler warning.
+
2009-11-25 Eric Blake <ebb9@byu.net>
Allow use of compiler warnings.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 33aa0df0..2440df0a 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests --makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update gnumakefile gnupload gpl-3.0 intprops maintainer-makefile manywarnings memchr2 mkstemp obstack pipe progname regex sigaction stdbool stdint stdlib-safer strsignal strstr strtod strtol unlocked-io update-copyright vc-list-files verror version-etc version-etc-fsf wait-process xalloc xprintf xvasprintf-posix
+# gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --with-tests --avoid=lock-tests --avoid=tls-tests --makefile-name=gnulib.mk --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h dirname error execute fdl-1.3 fflush filenamecat fopen fopen-safer fseeko gendocs getopt-gnu git-version-gen gnu-web-doc-update gnumakefile gnupload gpl-3.0 ignore-value intprops maintainer-makefile manywarnings memchr2 mkstemp obstack pipe progname regex sigaction stdbool stdint stdlib-safer strsignal strstr strtod strtol unlocked-io update-copyright vc-list-files verror version-etc version-etc-fsf wait-process xalloc xprintf xvasprintf-posix
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([local])
@@ -47,6 +47,7 @@ gl_MODULES([
gnumakefile
gnupload
gpl-3.0
+ ignore-value
intprops
maintainer-makefile
manywarnings
diff --git a/src/m4.c b/src/m4.c
index 685d022e..496b6e0d 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -26,6 +26,7 @@
#include <signal.h>
#include "c-stack.h"
+#include "ignore-value.h"
#include "progname.h"
#include "version-etc.h"
@@ -147,18 +148,21 @@ fault_handler (int signo)
async-safe. However, the static variables that we read are
never modified once this handler is installed, so this
particular usage is safe. And it seems an oversight that
- POSIX claims strlen is not async-safe. */
- write (STDERR_FILENO, program_name, strlen (program_name));
- write (STDERR_FILENO, ": ", 2);
- write (STDERR_FILENO, program_error_message,
+ POSIX claims strlen is not async-safe. Ignore write
+ failures, since we will exit with non-zero status anyway. */
+#define WRITE(f, b, l) ignore_value (write (f, b, l))
+ WRITE (STDERR_FILENO, program_name, strlen (program_name));
+ WRITE (STDERR_FILENO, ": ", 2);
+ WRITE (STDERR_FILENO, program_error_message,
strlen (program_error_message));
if (signal_message[signo])
{
- write (STDERR_FILENO, ": ", 2);
- write (STDERR_FILENO, signal_message[signo],
+ WRITE (STDERR_FILENO, ": ", 2);
+ WRITE (STDERR_FILENO, signal_message[signo],
strlen (signal_message[signo]));
}
- write (STDERR_FILENO, "\n", 1);
+ WRITE (STDERR_FILENO, "\n", 1);
+#undef WRITE
_exit (EXIT_INTERNAL_ERROR);
}
}