stackovf: use sigaction
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.gnu.m4.patches |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've finished writing a sigaction gnulib module that allows the blind use of sigaction even on mingw. As such, I can check this in on the stackovf branch: - -- Don't work too hard, make some time for fun as well! Eric Blake [email protected] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkhdgTkACgkQ84KuGfSFAYCy8QCfW1cmuImUUE8A+SmuuWsOt47A 5jkAn2j0Sf+t6MqQDsH5DHFOmXZyR4NA =HJ39 -----END PGP SIGNATURE----- _______________________________________________ M4-patches mailing list [email protected] http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch361
(text/plain, 5 KB)
From bb09ca5a7f38312fe279bd0e67d0c41dc65b8ba0 Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Sat, 21 Jun 2008 15:00:14 -0600 Subject: [PATCH] Use new sigaction module. * m4/gnulib-cache.m4: Import sigaction module. * src/m4.c (main): Drop signal() calls. Signed-off-by: Eric Blake <[email protected]> --- ChangeLog | 6 ++++++ m4/gnulib-cache.m4 | 4 ++-- src/m4.c | 30 ++++++++++-------------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9913112..d9f0d10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-21 Eric Blake <[email protected]> + + Use new sigaction module. + * m4/gnulib-cache.m4: Import sigaction module. + * src/m4.c (main): Drop signal() calls. + 2008-06-18 Eric Blake <[email protected]> Also trap SIGILL, SIGFPE, SIGBUS. diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 7f8d10b..b725169 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]) diff --git a/src/m4.c b/src/m4.c index a6665ff..970aa8b 100644 --- a/src/m4.c +++ b/src/m4.c @@ -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, -- 1.5.6