summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-09-11 15:53:17 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-05 14:45:56 +0100
commite90c65e609380c218ea25eada6fbdcad554f3ae7 (patch)
treec52be99f92eb579ab5243b9f877fc468a71ac065 /src/corelib/io/qprocess_unix.cpp
parentf31ff453c3f03ffae21ec9bcd64e9cd93547e6d2 (diff)
Centralise handling & ignoring of SIGPIPE in qcore_unix_p.h
We had two instances of this function in the Qt source code, one clearly a copy of the other, so both had the same thread-safety issue. Instead, let's have one copy and have both write_nosignal() and sendto() call them. (cherry-picked from qtbase commit cb7d64170d62c9cda11ced7e5047070af678338b) Change-Id: I0f1354a8e9df8e6b10a02f86a940e3c6d1222087 Reviewed-by: Peter Hartmann <phartmann@rim.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/corelib/io/qprocess_unix.cpp')
-rw-r--r--src/corelib/io/qprocess_unix.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 2feb6a5727..88a3249d29 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -958,27 +958,9 @@ qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen)
return bytesRead;
}
-static void qt_ignore_sigpipe()
-{
- // Set to ignore SIGPIPE once only.
- static QBasicAtomicInt atom = Q_BASIC_ATOMIC_INITIALIZER(0);
- if (!atom) {
- // More than one thread could turn off SIGPIPE at the same time
- // But that's acceptable because they all would be doing the same
- // action
- struct sigaction noaction;
- memset(&noaction, 0, sizeof(noaction));
- noaction.sa_handler = SIG_IGN;
- ::sigaction(SIGPIPE, &noaction, 0);
- atom = 1;
- }
-}
-
qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
{
- qt_ignore_sigpipe();
-
- qint64 written = qt_safe_write(stdinChannel.pipe[1], data, maxlen);
+ qint64 written = qt_safe_write_nosignal(stdinChannel.pipe[1], data, maxlen);
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::writeToStdin(%p \"%s\", %lld) == %lld",
data, qt_prettyDebug(data, maxlen, 16).constData(), maxlen, written);