summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-07-02 15:38:10 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-07-06 12:10:47 (GMT)
commit92b6ca830f279cfa9d37946f1fd72843b24e704b (patch)
tree5d7d5751b0dec7f37a75d1322304f2b4d8b52cf5 /src/corelib
parent4ebff202b44bb751a1c37db13963362592e86a6d (diff)
downloadQt-92b6ca830f279cfa9d37946f1fd72843b24e704b.zip
Qt-92b6ca830f279cfa9d37946f1fd72843b24e704b.tar.gz
Qt-92b6ca830f279cfa9d37946f1fd72843b24e704b.tar.bz2
fix bogus return value from qprocess::execute()
Task-number: QTBUG-230, QTBUG-5866 Reviewed-by: joerg
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qprocess.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 8eba2b0..4c21a40 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -2082,14 +2082,19 @@ QProcess::ExitStatus QProcess::exitStatus() const
process.
On Windows, arguments that contain spaces are wrapped in quotes.
+
+ If the process cannot be started, -2 is returned. If the process
+ crashes, -1 is returned. Otherwise, the process' exit code is
+ returned.
*/
int QProcess::execute(const QString &program, const QStringList &arguments)
{
QProcess process;
process.setReadChannelMode(ForwardedChannels);
process.start(program, arguments);
- process.waitForFinished(-1);
- return process.exitCode();
+ if (!process.waitForFinished(-1))
+ return -2;
+ return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1;
}
/*!
@@ -2104,8 +2109,9 @@ int QProcess::execute(const QString &program)
QProcess process;
process.setReadChannelMode(ForwardedChannels);
process.start(program);
- process.waitForFinished(-1);
- return process.exitCode();
+ if (!process.waitForFinished(-1))
+ return -2;
+ return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1;
}
/*!