summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-10-27 17:19:53 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-10-27 17:32:38 (GMT)
commitad342b62f1b4c6b9ca0997ddb937f3871f6d875b (patch)
treea43edcfb8a3f6c91a78fcaaa94a38ad7b0e1f0c9
parent2c672ea518265496a0fc7c5de63ca7dda880dd85 (diff)
downloadQt-ad342b62f1b4c6b9ca0997ddb937f3871f6d875b.zip
Qt-ad342b62f1b4c6b9ca0997ddb937f3871f6d875b.tar.gz
Qt-ad342b62f1b4c6b9ca0997ddb937f3871f6d875b.tar.bz2
Make QProcess report errors from a failed subprocess start.
Reviewed-by: João Abecasis
-rw-r--r--src/corelib/io/qprocess_unix.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 99296c7..f040d16 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -108,6 +108,10 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
+// POSIX requires PIPE_BUF to be 512 or larger
+// so we will use 512
+static const int errorBufferMax = 512;
+
#ifdef Q_OS_INTEGRITY
static inline char *strdup(const char *data)
{
@@ -752,18 +756,19 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
}
// notify failure
+ QString error = qt_error_string(errno);
#if defined (QPROCESS_DEBUG)
- fprintf(stderr, "QProcessPrivate::execChild() failed, notifying parent process\n");
+ fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", qPrintable(error));
#endif
- qt_safe_write(childStartedPipe[1], "", 1);
+ qt_safe_write(childStartedPipe[1], error.data(), error.length() * sizeof(QChar));
qt_safe_close(childStartedPipe[1]);
childStartedPipe[1] = -1;
}
bool QProcessPrivate::processStarted()
{
- char c;
- int i = qt_safe_read(childStartedPipe[0], &c, 1);
+ ushort buf[errorBufferMax];
+ int i = qt_safe_read(childStartedPipe[0], &buf, sizeof buf);
if (startupSocketNotifier) {
startupSocketNotifier->setEnabled(false);
startupSocketNotifier->deleteLater();
@@ -775,6 +780,11 @@ bool QProcessPrivate::processStarted()
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::processStarted() == %s", i <= 0 ? "true" : "false");
#endif
+
+ // did we read an error message?
+ if (i > 0)
+ q_func()->setErrorString(QString::fromUtf16(buf, i / sizeof(QChar)));
+
return i <= 0;
}