summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRitt Konstantin <ritt.ks@gmail.com>2011-01-11 11:33:33 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:44 (GMT)
commitc49bf50c8e603e6986ebc329e7776233483e98ab (patch)
tree751415927d58ee9d19472ec3ca853c81bfb062a9 /src
parent4e00ed2a97bf1438cc68911ac75d61d2330abea8 (diff)
downloadQt-c49bf50c8e603e6986ebc329e7776233483e98ab.zip
Qt-c49bf50c8e603e6986ebc329e7776233483e98ab.tar.gz
Qt-c49bf50c8e603e6986ebc329e7776233483e98ab.tar.bz2
make the modifySemaphore() signal-safe on linux
as POSIX man says, if semop() is interrupted by a signal, it shall return -1 and set errno to EINTR. in qcore_unix_p.h, we have EINTR_LOOP helper macro exactly for such cases ;) Task-number: QTBUG-14434 Merge-request: 998 Reviewed-by: Olivier Goffart
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qsystemsemaphore_unix.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp
index e76331e..7e45497 100644
--- a/src/corelib/kernel/qsystemsemaphore_unix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp
@@ -56,6 +56,8 @@
#include <sys/sem.h>
+#include "private/qcore_unix_p.h"
+
// OpenBSD 4.2 doesn't define EIDRM, see BUGS section:
// http://www.openbsd.org/cgi-bin/man.cgi?query=semop&manpath=OpenBSD+4.2
#if defined(Q_OS_OPENBSD) && !defined(EIDRM)
@@ -218,7 +220,10 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
operation.sem_num = 0;
operation.sem_op = count;
operation.sem_flg = SEM_UNDO;
- if (-1 == semop(semaphore, &operation, 1)) {
+
+ register int res;
+ EINTR_LOOP(res, semop(semaphore, &operation, 1));
+ if (-1 == res) {
// If the semaphore was removed be nice and create it and then modifySemaphore again
if (errno == EINVAL || errno == EIDRM) {
semaphore = -1;