[Xenomai-git] Jan Kiszka : lib/cobalt: restore pre-existing SIGDEBUG handler
Module: xenomai-forge Branch: master Commit: 56e85887c4b05e53afc359782c1b321d9589ece4 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=56e85887c4b05e53afc359782c1b321d9589ece4 Author: Jan Kiszka Date: Wed Mar 13 15:40:23 2013 +0100 lib/cobalt: 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 --- lib/cobalt/init.c |3 ++- lib/cobalt/internal.c | 12 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index 09eaaea..87e4afd 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -39,6 +39,7 @@ int __cobalt_muxid = -1; int __rtdm_muxid = -1; int __rtdm_fd_start = INT_MAX; +struct sigaction __cobalt_orig_sigdebug; static int fork_handler_registered; static pthread_t xeno_main_tid; struct xnfeatinfo xeno_featinfo; @@ -170,7 +171,7 @@ void __init_cobalt_interface(void) sa.sa_sigaction = cobalt_handle_sigdebug; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; - sigaction(SIGXCPU, &sa, NULL); + sigaction(SIGXCPU, &sa, &__cobalt_orig_sigdebug); cobalt_clock_init(muxid); diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c index 74cb391..706df7a 100644 --- a/lib/cobalt/internal.c +++ b/lib/cobalt/internal.c @@ -38,6 +38,8 @@ extern unsigned long xeno_sem_heap[2]; +extern struct sigaction __cobalt_orig_sigdebug; + void __cobalt_thread_harden(void) { unsigned long status = xeno_get_current_mode(); @@ -320,8 +322,6 @@ int cobalt_monitor_drain_all_sync(cobalt_monitor_t *mon) void cobalt_handle_sigdebug(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"); @@ -332,12 +332,10 @@ void cobalt_handle_sigdebug(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. +* restore the setting before we registered and re-raise the +* signal. Usually triggers the default signal action. */ - sa.sa_handler = SIG_DFL; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sigaction(SIGXCPU, &sa, NULL); + sigaction(SIGXCPU, &__cobalt_orig_sigdebug, NULL); pthread_kill(pthread_self(), SIGXCPU); } ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: restore pre-existing SIGDEBUG handler
Module: xenomai-forge Branch: next Commit: 56e85887c4b05e53afc359782c1b321d9589ece4 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=56e85887c4b05e53afc359782c1b321d9589ece4 Author: Jan Kiszka Date: Wed Mar 13 15:40:23 2013 +0100 lib/cobalt: 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 --- lib/cobalt/init.c |3 ++- lib/cobalt/internal.c | 12 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index 09eaaea..87e4afd 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -39,6 +39,7 @@ int __cobalt_muxid = -1; int __rtdm_muxid = -1; int __rtdm_fd_start = INT_MAX; +struct sigaction __cobalt_orig_sigdebug; static int fork_handler_registered; static pthread_t xeno_main_tid; struct xnfeatinfo xeno_featinfo; @@ -170,7 +171,7 @@ void __init_cobalt_interface(void) sa.sa_sigaction = cobalt_handle_sigdebug; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; - sigaction(SIGXCPU, &sa, NULL); + sigaction(SIGXCPU, &sa, &__cobalt_orig_sigdebug); cobalt_clock_init(muxid); diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c index 74cb391..706df7a 100644 --- a/lib/cobalt/internal.c +++ b/lib/cobalt/internal.c @@ -38,6 +38,8 @@ extern unsigned long xeno_sem_heap[2]; +extern struct sigaction __cobalt_orig_sigdebug; + void __cobalt_thread_harden(void) { unsigned long status = xeno_get_current_mode(); @@ -320,8 +322,6 @@ int cobalt_monitor_drain_all_sync(cobalt_monitor_t *mon) void cobalt_handle_sigdebug(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"); @@ -332,12 +332,10 @@ void cobalt_handle_sigdebug(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. +* restore the setting before we registered and re-raise the +* signal. Usually triggers the default signal action. */ - sa.sa_handler = SIG_DFL; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sigaction(SIGXCPU, &sa, NULL); + sigaction(SIGXCPU, &__cobalt_orig_sigdebug, NULL); pthread_kill(pthread_self(), SIGXCPU); } ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git
[Xenomai-git] Jan Kiszka : lib/cobalt: restore pre-existing SIGDEBUG handler
Module: xenomai-forge Branch: next Commit: 076bd93f21d38211c2b713b887fd089ae5ec5a10 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=076bd93f21d38211c2b713b887fd089ae5ec5a10 Author: Jan Kiszka Date: Wed Mar 13 15:40:23 2013 +0100 lib/cobalt: 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 --- lib/cobalt/init.c |3 ++- lib/cobalt/internal.c | 12 +--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/cobalt/init.c b/lib/cobalt/init.c index 09eaaea..87e4afd 100644 --- a/lib/cobalt/init.c +++ b/lib/cobalt/init.c @@ -39,6 +39,7 @@ int __cobalt_muxid = -1; int __rtdm_muxid = -1; int __rtdm_fd_start = INT_MAX; +struct sigaction __cobalt_orig_sigdebug; static int fork_handler_registered; static pthread_t xeno_main_tid; struct xnfeatinfo xeno_featinfo; @@ -170,7 +171,7 @@ void __init_cobalt_interface(void) sa.sa_sigaction = cobalt_handle_sigdebug; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; - sigaction(SIGXCPU, &sa, NULL); + sigaction(SIGXCPU, &sa, &__cobalt_orig_sigdebug); cobalt_clock_init(muxid); diff --git a/lib/cobalt/internal.c b/lib/cobalt/internal.c index 74cb391..706df7a 100644 --- a/lib/cobalt/internal.c +++ b/lib/cobalt/internal.c @@ -38,6 +38,8 @@ extern unsigned long xeno_sem_heap[2]; +extern struct sigaction __cobalt_orig_sigdebug; + void __cobalt_thread_harden(void) { unsigned long status = xeno_get_current_mode(); @@ -320,8 +322,6 @@ int cobalt_monitor_drain_all_sync(cobalt_monitor_t *mon) void cobalt_handle_sigdebug(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"); @@ -332,12 +332,10 @@ void cobalt_handle_sigdebug(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. +* restore the setting before we registered and re-raise the +* signal. Usually triggers the default signal action. */ - sa.sa_handler = SIG_DFL; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sigaction(SIGXCPU, &sa, NULL); + sigaction(SIGXCPU, &__cobalt_orig_sigdebug, NULL); pthread_kill(pthread_self(), SIGXCPU); } ___ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git