X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-ust-comm.c;h=0d4f5ef9e9c389656b23016c8e63191ce9dce923;hb=e32d20e94c6c0acb82cfacda4652fd566960c575;hp=0116b5f744160cab7d4077146d4a532f606359d8;hpb=545c85f844ecc49a62c6889e73d0bc466b8e6935;p=lttng-ust.git diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 0116b5f7..0d4f5ef9 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -837,6 +837,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; @@ -873,6 +874,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); @@ -883,6 +896,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 {