aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@smyrno.hos.anvin.org>2005-05-20 12:25:03 -0700
committerH. Peter Anvin <hpa@smyrno.hos.anvin.org>2005-05-20 12:25:03 -0700
commitde82c7b17af72c300eec0d17dd48e7cee6b896da (patch)
treea53fa0bd8ac044a1fd93f2cad7dfb61a49488003
parent1db8f1a3e7d4f4c2a4b3575471cb4df3318a3276 (diff)
downloadklibc-de82c7b17af72c300eec0d17dd48e7cee6b896da.tar.gz
Be TOTALLY obnoxiously anal about wrapping sigaction...klibc-1.0.10
-rw-r--r--klibc/sigaction.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/klibc/sigaction.c b/klibc/sigaction.c
index 01e6f616d9e75..85f42a244cc65 100644
--- a/klibc/sigaction.c
+++ b/klibc/sigaction.c
@@ -11,12 +11,16 @@ __extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *, s
int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
+ int rv;
+
#if defined(__i386__) || defined(__x86_64__)
/* x86-64, and the Fedora i386 kernel, are broken without SA_RESTORER */
- struct sigaction sa = *act;
- act = &sa;
+ struct sigaction sa;
+
+ if ( act && !(act->sa_flags & SA_RESTORER) ) {
+ sa = *act;
+ act = &sa;
- if ( !(sa.sa_flags & SA_RESTORER) ) {
/* The kernel can't be trusted to have a valid default restorer */
sa.sa_flags |= SA_RESTORER;
sa.sa_restorer = &__sigreturn;
@@ -24,8 +28,17 @@ int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
#endif
#ifdef __NR_sigaction
- return __sigaction(sig, act, oact);
+ rv = __sigaction(sig, act, oact);
#else
- return __rt_sigaction(sig, act, oact, sizeof(sigset_t));
+ rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
+#endif
+
+
+#if defined(__i386__) || defined(__x86_64__)
+ if ( oact && (oact->sa_restorer == &__sigreturn) ) {
+ oact->sa_flags &= ~SA_RESTORER;
+ }
#endif
+
+ return rv;
}