diff options
authorRich Felker <>2013-08-10 23:39:43 -0400
committerRich Felker <>2013-08-10 23:39:43 -0400
commit7c440977db9444d7e6b1c3dcb1fdf4ee49ca4158 (patch)
parent41c632824c08ac2c9eea43b30d1b3515dd910df6 (diff)
fix _NSIG and SIGRTMAX on mips
a mips signal mask contains 128 bits, enough for signals 1 through 128. however, the exit status obtained from the wait-family functions only has room for values up to 127. reportedly signal 128 was causing kernelspace bugs, so it was removed from the kernel recently; even without that issue, however, it was impossible to support it correctly in userspace. at the same time, the bug was masked on musl by SIGRTMAX incorrectly yielding 64 on mips, rather than the "correct" value of 128. now that the _NSIG issue is fixed, SIGRTMAX can be fixed at the same time, exposing the full range of signals for application use. note that the (nonstandardized) libc _NSIG value is actually one greater than the max signal number, and also one greater than the kernel headers' idea of _NSIG. this is the reason for the discrepency with the recent kernel changes. since reducing _NSIG by one brought it down from 129 to 128, rather than from 128 to 127, _NSIG/8, used widely in the musl sources, is unchanged.
2 files changed, 4 insertions, 2 deletions
diff --git a/arch/mips/bits/signal.h b/arch/mips/bits/signal.h
index 857d3c07..56ccdb73 100644
--- a/arch/mips/bits/signal.h
+++ b/arch/mips/bits/signal.h
@@ -100,4 +100,4 @@ typedef struct __ucontext {
#define SIGXFSZ 31
-#define _NSIG 129
+#define _NSIG 128
diff --git a/src/signal/sigrtmax.c b/src/signal/sigrtmax.c
index 0ef29873..44dc88ff 100644
--- a/src/signal/sigrtmax.c
+++ b/src/signal/sigrtmax.c
@@ -1,4 +1,6 @@
+#include <signal.h>
int __libc_current_sigrtmax()
- return 64;
+ return _NSIG-1;