From db2fc7843c031c450799269ad82f379d358f29a5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2015 17:41:15 -0700 Subject: QProcess: make setWorkingDirectory stop launch if the dir doesn't exist [ChangeLog][QtCore][QProcess] Fixed a bug that caused QProcess to launch a child process on Unix even if the directory specified with setWorkingDirectory did not exist. Task-number: QTBUG-47271 Change-Id: Ib306f8f647014b399b87ffff13f195158b0e52f5 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_unix.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib/io/qprocess_unix.cpp') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 4c3432d6b6..63480dfc6b 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -672,9 +672,9 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv qt_safe_close(childStartedPipe[0]); // enter the working directory - if (workingDir) { - if (QT_CHDIR(workingDir) == -1) - qWarning("QProcessPrivate::execChild() failed to chdir to %s", workingDir); + if (workingDir && QT_CHDIR(workingDir) == -1) { + // failed, stop the process + goto report_errno; } // this is a virtual call, and it base behavior is to do nothing. @@ -703,6 +703,7 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv } // notify failure +report_errno: QString error = qt_error_string(errno); #if defined (QPROCESS_DEBUG) fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", qPrintable(error)); -- cgit v1.2.3