signal: work around Haiku issue with SIGBUS
authorEric Blake <eblake@redhat.com>
Fri, 31 Dec 2010 19:36:15 +0000 (12:36 -0700)
committerEric Blake <eblake@redhat.com>
Thu, 6 Jan 2011 21:21:48 +0000 (14:21 -0700)
* lib/siglist.h: Add comment.
* lib/sig2str.c (numname_table): Swap SIGBUS order, to match
strsignal's favoring of SIGSEGV.
* tests/test-signal.c (main): Avoid test failure.
* doc/posix-headers/signal.texi (signal.h): Document the issue.
Reported by Scott McCreary.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/posix-headers/signal.texi
lib/sig2str.c
lib/siglist.h
tests/test-signal.c

index 5e319f92c8c70d8441fe61eadc02b834db69d0a9..d638bdf9cf4c212e6896d827ddb0bfea03acb631 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
 2010-12-31  Eric Blake  <eblake@redhat.com>
 
+       signal: work around Haiku issue with SIGBUS
+       * lib/siglist.h: Add comment.
+       * lib/sig2str.c (numname_table): Swap SIGBUS order, to match
+       strsignal's favoring of SIGSEGV.
+       * tests/test-signal.c (main): Avoid test failure.
+       * doc/posix-headers/signal.texi (signal.h): Document the issue.
+       Reported by Scott McCreary.
+
        nl_langinfo: fix YESEXPR on Irix 6.5
        * m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Test for Irix bug.
        * lib/nl_langinfo.c (rpl_nl_langinfo): Work around it.
index 9056d1e3e6d968630e189c3e86e9a90aad3d7c8b..77a54323c3679719a6b2420e0f42e38c0741a36c 100644 (file)
@@ -39,4 +39,8 @@ mingw.
 The macros @code{SIGRTMIN} and @code{SIGRTMAX} expand to an expression of type
 @code{long} instead of @code{int} on some platforms:
 OSF/1 5.1.
+@item
+The macro @code{SIGBUS} is set to the same value as @code{SIGSEGV},
+rather than being a distinct signal, on some platforms:
+Haiku.
 @end itemize
index 770f88c00f2a0de7374842c3c63f78cfe17bb7a0..70faa66c35925ad51723787b01d05363bccf3f0a 100644 (file)
@@ -41,7 +41,7 @@
 static struct numname { int num; char const name[8]; } numname_table[] =
   {
     /* Signals required by POSIX 1003.1-2001 base, listed in
-       traditional numeric order.  */
+       traditional numeric order where possible.  */
 #ifdef SIGHUP
     NUMNAME (HUP),
 #endif
@@ -66,11 +66,13 @@ static struct numname { int num; char const name[8]; } numname_table[] =
 #ifdef SIGKILL
     NUMNAME (KILL),
 #endif
-#ifdef SIGBUS
-    NUMNAME (BUS),
-#endif
 #ifdef SIGSEGV
     NUMNAME (SEGV),
+#endif
+    /* On Haiku, SIGSEGV == SIGBUS, but we prefer SIGSEGV to match
+       strsignal.c output, so SIGBUS must be listed second.  */
+#ifdef SIGBUS
+    NUMNAME (BUS),
 #endif
 #ifdef SIGPIPE
     NUMNAME (PIPE),
index 8c86d9b22223fee96da6340a1bb9112dc932a2d1..104bc68310ce54151ad995a352aa962a3906a6e5 100644 (file)
@@ -23,6 +23,9 @@
 
 /* This file is included multiple times.  */
 
+/* Duplicate values (such as SIGBUS==SIGSEGV on Haiku) favor the last
+   list entry.  */
+
 /* Standard signals  */
 #ifdef SIGHUP
   init_sig (SIGHUP, "HUP", N_("Hangup"))
index 116fe052794a13eab3444cd72d15030142b5b9d6..7103e1ff19cddd1d1ac39a8baf1dcf8420d792cc 100644 (file)
@@ -59,7 +59,8 @@ main (void)
 #ifdef SIGALRM
     case SIGALRM:
 #endif
-#ifdef SIGBUS
+      /* On Haiku, SIGBUS is mistakenly equal to SIGSEGV.  */
+#if defined SIGBUS && SIGBUS != SIGSEGV
     case SIGBUS:
 #endif
 #ifdef SIGCHLD