diff options
author | Yorhel <git@yorhel.nl> | 2014-04-03 08:50:29 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2014-04-03 08:50:29 +0200 |
commit | 77ecca991f6775668f7b4213fde7a7beb01575f4 (patch) | |
tree | 1ed0080b42e948cb3128990c52a2bb9268ca1a53 /evtp.c | |
parent | cdeba6e7e187d6295b319337067e8c445a662a3f (diff) |
evtp: Don't inherit signal mask in worker threads
Thanks to Marc Lehmann for pointing out this problem and suggesting the
fix: http://lists.schmorp.de/pipermail/libev/2014q2/002368.html
Diffstat (limited to 'evtp.c')
-rw-r--r-- | evtp.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -32,6 +32,7 @@ #include <errno.h> #include <assert.h> #include <pthread.h> +#include <signal.h> typedef struct evtp_queue_t { @@ -161,11 +162,18 @@ static int evtp_spawn(evtp_t *tp) { tp->kill--; return 1; } - pthread_t thread; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + sigset_t fullset, oldset; + sigfillset(&fullset); + + pthread_t thread; + pthread_sigmask(SIG_SETMASK, &fullset, &oldset); int r = pthread_create(&thread, &attr, evtp_thread, tp); + pthread_sigmask(SIG_SETMASK, &oldset, NULL); + if(r) { errno = r; return tp->threads ? 0 : -1; |