summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2014-03-06 22:53:38 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 16:18:17 (GMT)
commit54491a2571669f0c232d2ab9926991ff9ecf3403 (patch)
treee65a611ab1f945267a495d24eaf401452217618a
parent1f35d0783cc2a742d94d4f8e33819835dc990d87 (diff)
downloadQt-54491a2571669f0c232d2ab9926991ff9ecf3403.zip
Qt-54491a2571669f0c232d2ab9926991ff9ecf3403.tar.gz
Qt-54491a2571669f0c232d2ab9926991ff9ecf3403.tar.bz2
do not use fileno calls in forked child
This fixes an issue that causes QProcess::start to silently fail on OS X 10.9. Apparently, fileno(stdout) locks the handle on OS X 10.9. It may happen that the parent process fflush()s stdout while the child has just been forked. The stdout lock of the parent is never released in the child and fileno(stdout) therefore locks forever. According to the fork documentation on opengroup.org one may only call async-signal-safe functions between fork and exec in the child. The fileno() function does not appear in the list of async-signal-safe functions. Also, fileno(stdout) and friends can be easily replaced by the standard constants STDOUT_FILENO etc. Done-with: Fawzi Mohamed <fawzi.mohamed@digia.com> Task-number: QTBUG-37306 Change-Id: I2b1f5f47cc48a1ad020fb0493a955d2bc27aeb47 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from qtbase/b2216bbe06b8be2bef6d8bc2ffff1337f6d23358)
-rw-r--r--src/corelib/io/qprocess_unix.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 6fa658e..ce2657c 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -774,17 +774,17 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
Q_Q(QProcess);
// copy the stdin socket (without closing on exec)
- qt_safe_dup2(stdinChannel.pipe[0], QT_FILENO(stdin), 0);
+ qt_safe_dup2(stdinChannel.pipe[0], STDIN_FILENO, 0);
// copy the stdout and stderr if asked to
if (processChannelMode != QProcess::ForwardedChannels) {
- qt_safe_dup2(stdoutChannel.pipe[1], QT_FILENO(stdout), 0);
+ qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0);
// merge stdout and stderr if asked to
if (processChannelMode == QProcess::MergedChannels) {
- qt_safe_dup2(QT_FILENO(stdout), QT_FILENO(stderr), 0);
+ qt_safe_dup2(STDOUT_FILENO, STDERR_FILENO, 0);
} else {
- qt_safe_dup2(stderrChannel.pipe[1], QT_FILENO(stderr), 0);
+ qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0);
}
}