Module: xenomai-jki
Branch: for-upstream
Commit: d1df66c96dc9ee83b214c165fa40ccdc662b2910
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=d1df66c96dc9ee83b214c165fa40ccdc662b2910

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Wed Mar 13 15:40:23 2013 +0100

Restore pre-existing SIGDEBUG handler

In case the application already set a SIGDEBUG handler, let that one
handle any events that aren't SIGDEBUG_NOMLOCK. This helps in scenarios
where skin libraries are loaded belatedly via dlopen.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/asm-generic/bits/bind.h |    4 +++-
 src/skins/common/bind.c         |   12 ++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/include/asm-generic/bits/bind.h b/include/asm-generic/bits/bind.h
index 269be95..57de2cf 100644
--- a/include/asm-generic/bits/bind.h
+++ b/include/asm-generic/bits/bind.h
@@ -5,6 +5,8 @@
 #include <stdlib.h>
 #include <signal.h>
 
+extern struct sigaction xeno_orig_sigdebug_sa;
+
 void xeno_handle_mlock_alert(int sig, siginfo_t *si, void *context);
 
 int 
@@ -26,7 +28,7 @@ xeno_bind_skin(unsigned skin_magic, const char *skin, const 
char *module)
        sa.sa_sigaction = xeno_handle_mlock_alert;
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = SA_SIGINFO;
-       sigaction(SIGXCPU, &sa, NULL);
+       sigaction(SIGXCPU, &sa, &xeno_orig_sigdebug_sa);
 
        return muxid;
 }
diff --git a/src/skins/common/bind.c b/src/skins/common/bind.c
index dabea59..c8153d4 100644
--- a/src/skins/common/bind.c
+++ b/src/skins/common/bind.c
@@ -14,6 +14,7 @@
 #include "sem_heap.h"
 
 int xeno_sigxcpu_no_mlock = 1;
+struct sigaction xeno_orig_sigdebug_sa;
 static pthread_t xeno_main_tid;
 
 static void xeno_sigill_handler(int sig)
@@ -117,8 +118,6 @@ void xeno_fault_stack(void)
 
 void xeno_handle_mlock_alert(int sig, siginfo_t *si, void *context)
 {
-       struct sigaction sa;
-
        if (si->si_value.sival_int == SIGDEBUG_NOMLOCK) {
                fprintf(stderr, "Xenomai: process memory not locked "
                        "(missing mlockall?)\n");
@@ -128,11 +127,8 @@ void xeno_handle_mlock_alert(int sig, siginfo_t *si, void 
*context)
 
        /* XNTRAPSW was set for the thread but no user-defined handler
           has been set to override our internal handler, so let's
-          invoke the default signal action. */
-
-       sa.sa_handler = SIG_DFL;
-       sigemptyset(&sa.sa_mask);
-       sa.sa_flags = 0;
-       sigaction(SIGXCPU, &sa, NULL);
+          restore the setting before we registered and re-raise the
+          signal. Usually triggers the default signal action. */
+       sigaction(SIGXCPU, &xeno_orig_sigdebug_sa, NULL);
        pthread_kill(pthread_self(), SIGXCPU);
 }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to