diff options
author | Pierre Ossman <ossman@cendio.se> | 2016-01-04 14:19:15 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2016-01-04 14:19:15 +0100 |
commit | a6b00267f2594923aa504629676927d94e0619ab (patch) | |
tree | 0a867a450ee5f22ecdf92eab137cef4f22d0fea0 /common/os | |
parent | 7b8ebff2f8bdc8218fa8dcd066e8c53fe5ea0822 (diff) | |
download | tigervnc-a6b00267f2594923aa504629676927d94e0619ab.tar.gz tigervnc-a6b00267f2594923aa504629676927d94e0619ab.zip |
Block signals from being handled on worker threads
Diffstat (limited to 'common/os')
-rw-r--r-- | common/os/Thread.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/os/Thread.cxx b/common/os/Thread.cxx index f38a10b7..2b08dbf9 100644 --- a/common/os/Thread.cxx +++ b/common/os/Thread.cxx @@ -20,6 +20,7 @@ #include <windows.h> #else #include <pthread.h> +#include <signal.h> #include <unistd.h> #endif @@ -64,8 +65,19 @@ void Thread::start() throw rdr::SystemException("Failed to create thread", GetLastError()); #else int ret; + sigset_t all, old; + + // Creating threads from libraries is a bit evil, so mitigate the + // issue by at least avoiding signals on these threads + sigfillset(&all); + ret = pthread_sigmask(SIG_SETMASK, &all, &old); + if (ret != 0) + throw rdr::SystemException("Failed to mask signals", ret); ret = pthread_create((pthread_t*)threadId, NULL, startRoutine, this); + + pthread_sigmask(SIG_SETMASK, &old, NULL); + if (ret != 0) throw rdr::SystemException("Failed to create thread", ret); #endif |