X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=libust%2Ftracectl.c;h=7a5cf9562282ce7fe90cc3d5e4c405d3bf44b8c6;hb=f51d84eac11907346fa02e33da358aad171ac80a;hp=3624b867f6d9f7a39bcae586878b00ae3abdd0b2;hpb=c3947c2532de17dc257f17e819501e02369f49b6;p=ust.git diff --git a/libust/tracectl.c b/libust/tracectl.c index 3624b86..7a5cf95 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1031,17 +1032,38 @@ static pthread_t listener_thread; void create_listener(void) { int result; + sigset_t sig_all_blocked; + sigset_t orig_parent_mask; if(have_listener) { WARN("not creating listener because we already had one"); return; } + /* A new thread created by pthread_create inherits the signal mask + * from the parent. To avoid any signal being received by the + * listener thread, we block all signals temporarily in the parent, + * while we create the listener thread. + */ + + sigfillset(&sig_all_blocked); + + result = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_parent_mask); + if(result) { + PERROR("pthread_sigmask: %s", strerror(result)); + } + result = pthread_create(&listener_thread, NULL, listener_main, NULL); if(result == -1) { PERROR("pthread_create"); } + /* Restore original signal mask in parent */ + result = pthread_sigmask(SIG_SETMASK, &orig_parent_mask, NULL); + if(result) { + PERROR("pthread_sigmask: %s", strerror(result)); + } + have_listener = 1; }