diff options
author | Eric Blake <ebb9@byu.net> | 2008-06-21 15:00:14 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2008-06-21 15:00:14 -0600 |
commit | bb09ca5a7f38312fe279bd0e67d0c41dc65b8ba0 (patch) | |
tree | 606de6210d4a0c2941ca6e12034a96f92133ac8d | |
parent | e0408e69edb2e966f9a4c879124e14ec4fcacf00 (diff) | |
download | m4-bb09ca5a7f38312fe279bd0e67d0c41dc65b8ba0.tar.gz |
Use new sigaction module.
* m4/gnulib-cache.m4: Import sigaction module.
* src/m4.c (main): Drop signal() calls.
Signed-off-by: Eric Blake <ebb9@byu.net>
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | m4/gnulib-cache.m4 | 4 | ||||
-rw-r--r-- | src/m4.c | 30 |
3 files changed, 18 insertions, 22 deletions
@@ -1,3 +1,9 @@ +2008-06-21 Eric Blake <ebb9@byu.net> + + Use new sigaction module. + * m4/gnulib-cache.m4: Import sigaction module. + * src/m4.c (main): Drop signal() calls. + 2008-06-18 Eric Blake <ebb9@byu.net> Also trap SIGILL, SIGFPE, SIGBUS. diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 7f8d10be..b7251692 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -15,11 +15,11 @@ # 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 --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack progname quote regex stdbool stdint stdlib-safer strsignal strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix +# gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack progname quote regex sigaction stdbool stdint stdlib-safer strsignal strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([local]) -gl_MODULES([announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack progname quote regex stdbool stdint stdlib-safer strsignal strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix]) +gl_MODULES([announce-gen assert autobuild avltree-oset binary-io c-stack clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack progname quote regex sigaction stdbool stdint stdlib-safer strsignal strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix]) gl_AVOID([]) gl_SOURCE_BASE([lib]) gl_M4_BASE([m4]) @@ -431,6 +431,7 @@ FILE *trace_file; int main (int argc, char *const *argv, char *const *envp) { + struct sigaction act; macro_definition *head; /* head of deferred argument list */ macro_definition *tail; macro_definition *defn; @@ -477,28 +478,17 @@ main (int argc, char *const *argv, char *const *envp) signal_message[SIGFPE] = xstrdup (strsignal (SIGFPE)); if (SIGBUS != SIGILL) signal_message[SIGBUS] = xstrdup (strsignal (SIGBUS)); -#ifdef HAVE_SIGACTION - { - struct sigaction act; - sigemptyset (&act.sa_mask); - /* One-shot - if we fault while handling a fault, we want to - revert to default signal behavior. */ - act.sa_flags = SA_NODEFER | SA_RESETHAND; - act.sa_handler = fault_handler; - sigaction (SIGABRT, &act, NULL); - sigaction (SIGILL, &act, NULL); - sigaction (SIGFPE, &act, NULL); - sigaction (SIGBUS, &act, NULL); - } -#else /* !HAVE_SIGACTION */ - signal (SIGABRT, fault_handler); - signal (SIGILL, fault_handler); - signal (SIGFPE, fault_handler); - signal (SIGBUS, fault_handler); -#endif /* !HAVE_SIGACTION */ + sigemptyset (&act.sa_mask); + /* One-shot - if we fault while handling a fault, we want to revert + to default signal behavior. */ + act.sa_flags = SA_NODEFER | SA_RESETHAND; + act.sa_handler = fault_handler; + sigaction (SIGABRT, &act, NULL); + sigaction (SIGILL, &act, NULL); + sigaction (SIGFPE, &act, NULL); + sigaction (SIGBUS, &act, NULL); /* First, we decode the arguments, to size up tables and stuff. */ - head = tail = NULL; while ((optchar = getopt_long (argc, (char **) argv, OPTSTRING, |