Take into account the role of SIGABRT_COMPAT on Windows 2008.
authorBruno Haible <bruno@clisp.org>
Mon, 20 Oct 2008 23:12:33 +0000 (01:12 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 20 Oct 2008 23:12:33 +0000 (01:12 +0200)
ChangeLog
lib/sigaction.c
lib/sigprocmask.c

index 4b3429d..86b9c18 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2008-10-20  Bruno Haible  <bruno@clisp.org>
 
+       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 <ramiro.polla@gmail.com> via Eric Blake.
+
+2008-10-20  Bruno Haible  <bruno@clisp.org>
+
        * lib/fts.c: Don't include lstat.h.
        * lib/openat.c: Include <sys/stat.h> instead of lstat.h.
 
index 1bad809..5fcd3ed 100644 (file)
 # 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
index 7f73f95..7b486a2 100644 (file)
 # 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