summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libc/signal/allocrtsig.c2
-rw-r--r--libc/signal/sigaction.c15
-rw-r--r--libc/signal/sigfillset.c9
-rw-r--r--libc/sysdeps/linux/arm/sigaction.c4
-rw-r--r--libc/sysdeps/linux/common/sigprocmask.c50
-rw-r--r--libc/sysdeps/linux/i386/sigaction.c3
-rw-r--r--libc/sysdeps/linux/mips/sigaction.c50
-rw-r--r--libc/sysdeps/linux/x86_64/sigaction.c2
8 files changed, 90 insertions, 45 deletions
diff --git a/libc/signal/allocrtsig.c b/libc/signal/allocrtsig.c
index 2102a15ba..ac6ba50d7 100644
--- a/libc/signal/allocrtsig.c
+++ b/libc/signal/allocrtsig.c
@@ -32,7 +32,7 @@
static int current_rtmin = -1;
static int current_rtmax = -1;
#else
-static int current_rtmin = __SIGRTMIN;
+static int current_rtmin = __SIGRTMIN + 2;
static int current_rtmax = __SIGRTMAX;
#endif
diff --git a/libc/signal/sigaction.c b/libc/signal/sigaction.c
index eb6b43a49..4b8503276 100644
--- a/libc/signal/sigaction.c
+++ b/libc/signal/sigaction.c
@@ -32,12 +32,6 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
int result;
struct kernel_sigaction kact, koact;
-#ifdef SIGCANCEL
- if (sig == SIGCANCEL) {
- __set_errno (EINVAL);
- return -1;
- }
-#endif
if (act) {
kact.k_sa_handler = act->sa_handler;
memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
@@ -73,12 +67,6 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
int result;
struct old_kernel_sigaction kact, koact;
-#ifdef SIGCANCEL
- if (sig == SIGCANCEL) {
- __set_errno (EINVAL);
- return -1;
- }
-#endif
if (act) {
kact.k_sa_handler = act->sa_handler;
kact.sa_mask = act->sa_mask.__val[0];
@@ -103,5 +91,6 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
#endif
+#ifndef LIBC_SIGACTION
weak_alias(__libc_sigaction, sigaction)
-
+#endif
diff --git a/libc/signal/sigfillset.c b/libc/signal/sigfillset.c
index 6edbb0e6b..735359cf0 100644
--- a/libc/signal/sigfillset.c
+++ b/libc/signal/sigfillset.c
@@ -31,5 +31,14 @@ int sigfillset (sigset_t *set)
memset (set, 0xff, sizeof (sigset_t));
+ /* If implementation uses a cancellation signal don't set the bit. */
+#ifdef SIGCANCEL
+ __sigdelset (set, SIGCANCEL);
+#endif
+ /* Likewise for the signal to implement setxid. */
+#ifdef SIGSETXID
+ __sigdelset (set, SIGSETXID);
+#endif
+
return 0;
}
diff --git a/libc/sysdeps/linux/arm/sigaction.c b/libc/sysdeps/linux/arm/sigaction.c
index 5fbb7fbf1..df9ea4c35 100644
--- a/libc/sysdeps/linux/arm/sigaction.c
+++ b/libc/sysdeps/linux/arm/sigaction.c
@@ -132,5 +132,7 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
}
#endif
-weak_alias(__libc_sigaction, sigaction)
+#ifndef LIBC_SIGACTION
+weak_alias(__libc_sigaction, sigaction)
+#endir
diff --git a/libc/sysdeps/linux/common/sigprocmask.c b/libc/sysdeps/linux/common/sigprocmask.c
index 70ff36606..3f42b09b8 100644
--- a/libc/sysdeps/linux/common/sigprocmask.c
+++ b/libc/sysdeps/linux/common/sigprocmask.c
@@ -18,8 +18,30 @@
_syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
sigset_t *, oldset, size_t, size);
-int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
+int __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
+#ifdef SIGCANCEL
+ sigset_t local_newmask;
+
+ /*
+ * The only thing we have to make sure here is that SIGCANCEL and
+ * SIGSETXID are not blocked.
+ */
+ if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+# ifdef SIGSETXID
+ || __builtin_expect (__sigismember (set, SIGSETXID), 0)
+# endif
+ ))
+ {
+ local_newmask = *set;
+ __sigdelset (&local_newmask, SIGCANCEL);
+# ifdef SIGSETXID
+ __sigdelset (&local_newmask, SIGSETXID);
+# endif
+ set = &local_newmask;
+ }
+#endif
+
if (set &&
#if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
(((unsigned int) how) > 2)
@@ -43,8 +65,30 @@ static inline
_syscall3(int, __syscall_sigprocmask, int, how, const sigset_t *, set,
sigset_t *, oldset);
-int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
+int __sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
{
+#ifdef SIGCANCEL
+ sigset_t local_newmask;
+
+ /*
+ * The only thing we have to make sure here is that SIGCANCEL and
+ * SIGSETXID are not blocked.
+ */
+ if (set != NULL && (__builtin_expect (__sigismember (set, SIGCANCEL), 0)
+# ifdef SIGSETXID
+ || __builtin_expect (__sigismember (set, SIGSETXID), 0)
+# endif
+ ))
+ {
+ local_newmask = *set;
+ __sigdelset (&local_newmask, SIGCANCEL);
+# ifdef SIGSETXID
+ __sigdelset (&local_newmask, SIGSETXID);
+# endif
+ set = &local_newmask;
+ }
+#endif
+
if (set &&
#if (SIG_BLOCK == 0) && (SIG_UNBLOCK == 1) && (SIG_SETMASK == 2)
(((unsigned int) how) > 2)
@@ -60,3 +104,5 @@ int sigprocmask(int how, const sigset_t * set, sigset_t * oldset)
return (__syscall_sigprocmask(how, set, oldset));
}
#endif
+
+weak_alias (__sigprocmask, sigprocmask)
diff --git a/libc/sysdeps/linux/i386/sigaction.c b/libc/sysdeps/linux/i386/sigaction.c
index 33c811e40..229a95ff5 100644
--- a/libc/sysdeps/linux/i386/sigaction.c
+++ b/libc/sysdeps/linux/i386/sigaction.c
@@ -121,7 +121,10 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
}
#endif
+
+#ifndef LIBC_SIGACTION
weak_alias (__libc_sigaction, sigaction)
+#endif
diff --git a/libc/sysdeps/linux/mips/sigaction.c b/libc/sysdeps/linux/mips/sigaction.c
index 79bbdae5e..4cbdc7023 100644
--- a/libc/sysdeps/linux/mips/sigaction.c
+++ b/libc/sysdeps/linux/mips/sigaction.c
@@ -25,10 +25,10 @@
#include <sys/syscall.h>
#include <bits/kernel_sigaction.h>
-#define SA_RESTORER 0x04000000
-
#if defined __NR_rt_sigaction
+#warning "Yes there is a warning here. Don't worry about it."
+static void restore_rt (void) asm ("__restore_rt");
/* If ACT is not NULL, change the action for SIG to *ACT.
If OACT is not NULL, put the old action for SIG in *OACT. */
@@ -37,22 +37,17 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
int result;
struct kernel_sigaction kact, koact;
-#ifdef SIGCANCEL
- if (sig == SIGCANCEL) {
- __set_errno (EINVAL);
- return -1;
- }
-#endif
-
if (act) {
kact.k_sa_handler = act->sa_handler;
memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
kact.sa_flags = act->sa_flags;
-
- kact.sa_flags = act->sa_flags | SA_RESTORER;
-#ifdef HAVE_SA_RESTORER
+# ifdef HAVE_SA_RESTORER
+# if _MIPS_SIM == _ABIO32
kact.sa_restorer = act->sa_restorer;
-#endif
+# else
+ kact.sa_restorer = &restore_rt;
+# endif
+# endif
}
/* XXX The size argument hopefully will have to be changed to the
@@ -64,9 +59,9 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
oact->sa_handler = koact.k_sa_handler;
memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (oact->sa_mask));
oact->sa_flags = koact.sa_flags;
-#ifdef HAVE_SA_RESTORER
+# ifdef HAVE_SA_RESTORER
oact->sa_restorer = koact.sa_restorer;
-#endif
+# endif
}
return result;
}
@@ -83,20 +78,17 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
int result;
struct old_kernel_sigaction kact, koact;
-#ifdef SIGCANCEL
- if (sig == SIGCANCEL) {
- __set_errno (EINVAL);
- return -1;
- }
-#endif
-
if (act) {
kact.k_sa_handler = act->sa_handler;
kact.sa_mask = act->sa_mask.__val[0];
- kact.sa_flags = act->sa_flags | SA_RESTORER;
-#ifdef HAVE_SA_RESTORER
+ kact.sa_flags = act->sa_flags;
+# ifdef HAVE_SA_RESTORER
+# if _MIPS_SIM == _ABIO32
kact.sa_restorer = act->sa_restorer;
-#endif
+# else
+ kact.sa_restorer = &restore_rt;
+# endif
+# endif
}
result = __syscall_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
@@ -111,13 +103,15 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
oact->sa_handler = koact.k_sa_handler;
oact->sa_mask.__val[0] = koact.sa_mask;
oact->sa_flags = koact.sa_flags;
-#ifdef HAVE_SA_RESTORER
+# ifdef HAVE_SA_RESTORER
oact->sa_restorer = koact.sa_restorer;
-#endif
+# endif
}
return result;
}
#endif
-weak_alias (__libc_sigaction, sigaction)
+#ifndef LIBC_SIGACTION
+weak_alias (__libc_sigaction, sigaction)
+#endif
diff --git a/libc/sysdeps/linux/x86_64/sigaction.c b/libc/sysdeps/linux/x86_64/sigaction.c
index 75eb46784..3ea9ad7d3 100644
--- a/libc/sysdeps/linux/x86_64/sigaction.c
+++ b/libc/sysdeps/linux/x86_64/sigaction.c
@@ -106,7 +106,9 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
}
#endif
+#ifndef LIBC_SIGACTION
weak_alias (__libc_sigaction, sigaction)
+#endif
/* NOTE: Please think twice before making any changes to the bits of
code below. GDB needs some intimate knowledge about it to