From d8374ab0f478c73f395110911d5e68ff0dfec837 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 21 Oct 2008 01:12:33 +0200 Subject: [PATCH] Take into account the role of SIGABRT_COMPAT on Windows 2008. --- ChangeLog | 10 ++++++++++ lib/sigaction.c | 13 +++++++++++++ lib/sigprocmask.c | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b3429dcd..86b9c189e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2008-10-20 Bruno Haible + Take into account the role of SIGABRT_COMPAT on Windows 2008. + * lib/sigprocmask.c (SIGABRT_COMPAT, SIGABRT_COMPAT_MASK): New macros. + (sigismember, sigaddset, sigdelset, sigfillset, rpl_signal): Handle it + as an alias for SIGABRT. + * lib/sigaction.c (SIGABRT_COMPAT): New macro. + (sigaction): Map it to SIGABRT. + Reported by Ramiro Polla via Eric Blake. + +2008-10-20 Bruno Haible + * lib/fts.c: Don't include lstat.h. * lib/openat.c: Include instead of lstat.h. diff --git a/lib/sigaction.c b/lib/sigaction.c index 1bad8092f..5fcd3ed9a 100644 --- a/lib/sigaction.c +++ b/lib/sigaction.c @@ -64,6 +64,14 @@ # define SIGSTOP (-1) #endif +/* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias + for the signal SIGABRT. Only one signal handler is stored for both + SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# undef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif + /* A signal handler. */ typedef void (*handler_t) (int signal); @@ -134,6 +142,11 @@ sigaction (int sig, const struct sigaction *restrict act, return -1; } + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + /* POSIX requires sigaction() to be async-signal-safe. In other words, if an asynchronous signal can occur while we are anywhere inside this function, the user's handler could then call diff --git a/lib/sigprocmask.c b/lib/sigprocmask.c index 7f73f951c..7b486a2b0 100644 --- a/lib/sigprocmask.c +++ b/lib/sigprocmask.c @@ -43,6 +43,19 @@ # define SIGSTOP (-1) #endif +/* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias + for the signal SIGABRT. Only one signal handler is stored for both + SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# undef SIGABRT_COMPAT +# define SIGABRT_COMPAT 6 +#endif +#ifdef SIGABRT_COMPAT +# define SIGABRT_COMPAT_MASK (1U << SIGABRT_COMPAT) +#else +# define SIGABRT_COMPAT_MASK 0 +#endif + typedef void (*handler_t) (int); /* Handling of gnulib defined signals. */ @@ -74,7 +87,14 @@ int sigismember (const sigset_t *set, int sig) { if (sig >= 0 && sig < NSIG) - return (*set >> sig) & 1; + { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + + return (*set >> sig) & 1; + } else return 0; } @@ -91,6 +111,11 @@ sigaddset (sigset_t *set, int sig) { if (sig >= 0 && sig < NSIG) { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + *set |= 1U << sig; return 0; } @@ -106,6 +131,11 @@ sigdelset (sigset_t *set, int sig) { if (sig >= 0 && sig < NSIG) { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + *set &= ~(1U << sig); return 0; } @@ -116,10 +146,11 @@ sigdelset (sigset_t *set, int sig) } } + int sigfillset (sigset_t *set) { - *set = (2U << (NSIG - 1)) - 1; + *set = ((2U << (NSIG - 1)) - 1) & ~ SIGABRT_COMPAT_MASK; return 0; } @@ -241,6 +272,11 @@ rpl_signal (int sig, handler_t handler) if (sig >= 0 && sig < NSIG && sig != SIGKILL && sig != SIGSTOP && handler != SIG_ERR) { + #ifdef SIGABRT_COMPAT + if (sig == SIGABRT_COMPAT) + sig = SIGABRT; + #endif + if (blocked_set & (1U << sig)) { /* POSIX states that sigprocmask and signal are both -- 2.11.0