Be TOTALLY obnoxiously anal about wrapping sigaction...
diff --git a/klibc/sigaction.c b/klibc/sigaction.c
index 01e6f61..85f42a2 100644
--- a/klibc/sigaction.c
+++ b/klibc/sigaction.c
@@ -11,12 +11,16 @@
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 ( !(sa.sa_flags & SA_RESTORER) ) {
+ if ( act && !(act->sa_flags & SA_RESTORER) ) {
+ sa = *act;
+ act = &sa;
+
/* 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 @@
#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;
}