summaryrefslogtreecommitdiffstats
path: root/qtools/qthread_unix.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2012-09-30 13:51:29 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2012-09-30 13:51:29 (GMT)
commitceb4115c7b941039411e1793e01239610ff112a2 (patch)
treed18c06222e0f84d6077b586e5633053a8bc09da8 /qtools/qthread_unix.cpp
parentf6d511e52eb55c5d5b980c4d226f2ea80b396095 (diff)
downloadDoxygen-ceb4115c7b941039411e1793e01239610ff112a2.zip
Doxygen-ceb4115c7b941039411e1793e01239610ff112a2.tar.gz
Doxygen-ceb4115c7b941039411e1793e01239610ff112a2.tar.bz2
Release-1.8.2-20120930
Diffstat (limited to 'qtools/qthread_unix.cpp')
-rw-r--r--qtools/qthread_unix.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/qtools/qthread_unix.cpp b/qtools/qthread_unix.cpp
index 5a7b788..b536583 100644
--- a/qtools/qthread_unix.cpp
+++ b/qtools/qthread_unix.cpp
@@ -52,6 +52,7 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
+#include <signal.h>
#include <unistd.h>
#include <stdio.h>
@@ -118,6 +119,13 @@ void QThread::start()
QMutexLocker locker(&d->mutex);
if (d->running) return;
+ // Block the SIGINT signal. The threads will inherit the signal mask.
+ // This will avoid them catching SIGINT instead of this thread.
+ sigset_t sigset, oldset;
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ pthread_sigmask(SIG_BLOCK, &sigset, &oldset);
+
d->running = TRUE;
d->finished = FALSE;
@@ -142,6 +150,11 @@ void QThread::start()
d->finished = FALSE;
d->thread_id = 0;
}
+ else
+ {
+ // Restore the old signal mask only for this thread.
+ pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+ }
}
void QThread::terminate()
@@ -182,7 +195,7 @@ int QThread::idealThreadCount()
int cores = -1;
#if defined(_OS_MAC_)
// Mac OS X
- cores = MPProcessorsScheduled();
+ cores = (int)MPProcessorsScheduled();
#elif defined(_OS_HPUX_)
// HP-UX
struct pst_dynamic psd;