X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-comm.c;h=76c8ee3da149ff49ecfe4633d7904927f1683de9;hb=ae6a58bf72561c5b87594bb04764313c325437a9;hp=0765c9b538a6a9370570647fea6780fe49070705;hpb=231227ee22e4f2d4f1967bc421f7988a5eaabfa3;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 0765c9b5..76c8ee3d 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -832,6 +832,7 @@ int get_timeout(struct timespec *constructor_timeout) void __attribute__((constructor)) lttng_ust_init(void) { struct timespec constructor_timeout; + sigset_t sig_all_blocked, orig_parent_mask; int timeout_mode; int ret; @@ -868,6 +869,18 @@ void __attribute__((constructor)) lttng_ust_init(void) if (ret) { ERR("Error setting up to local apps"); } + + /* 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); + ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_parent_mask); + if (ret) { + PERROR("pthread_sigmask: %s", strerror(ret)); + } + ret = pthread_create(&local_apps.ust_listener, NULL, ust_listener_thread, &local_apps); @@ -878,6 +891,12 @@ void __attribute__((constructor)) lttng_ust_init(void) handle_register_done(&local_apps); } + /* Restore original signal mask in parent */ + ret = pthread_sigmask(SIG_SETMASK, &orig_parent_mask, NULL); + if (ret) { + PERROR("pthread_sigmask: %s", strerror(ret)); + } + switch (timeout_mode) { case 1: /* timeout wait */ do {