[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] signal: work around Haiku issue with SIGBUS
From: |
Eric Blake |
Subject: |
[PATCH] signal: work around Haiku issue with SIGBUS |
Date: |
Fri, 31 Dec 2010 12:44:00 -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 <address@hidden>
---
> Thanks for tracking that. In glancing through gnulib uses of SIGBUS, it
> looks like most are harmless (it may end up associating the same handler
> with SIGSEGV twice in a row), but at least tests/test-signal.c will fail
> if we don't modify it to account for this bug. Also, we want to favor
> the name SIGSEGV in lists like strsignal(SIGBUS). And documenting the
> bug can't hurt. Patch coming up shortly.
I don't have access to Haiku, or I would test this. Does it look okay?
ChangeLog | 8 ++++++++
doc/posix-headers/signal.texi | 4 ++++
lib/sig2str.c | 10 ++++++----
lib/siglist.h | 3 +++
tests/test-signal.c | 3 ++-
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 12ab93b..38c4065 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2010-12-31 Eric Blake <address@hidden>
+ 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.
diff --git a/doc/posix-headers/signal.texi b/doc/posix-headers/signal.texi
index 9056d1e..77a5432 100644
--- a/doc/posix-headers/signal.texi
+++ b/doc/posix-headers/signal.texi
@@ -39,4 +39,8 @@ signal.h
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.
address@hidden
+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
diff --git a/lib/sig2str.c b/lib/sig2str.c
index fce22c0..99167cf 100644
--- a/lib/sig2str.c
+++ b/lib/sig2str.c
@@ -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,12 +66,14 @@ 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),
#endif
diff --git a/lib/siglist.h b/lib/siglist.h
index e372429..4783fa6 100644
--- a/lib/siglist.h
+++ b/lib/siglist.h
@@ -24,6 +24,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"))
diff --git a/tests/test-signal.c b/tests/test-signal.c
index 71c6061..3e759d7 100644
--- a/tests/test-signal.c
+++ b/tests/test-signal.c
@@ -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
--
1.7.3.4