From d5b591e828cb2de435907842dee371cfe2d13e48 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 24 Sep 2013 10:32:32 +0200 Subject: [PATCH] Work around wrong return code from pclose When we do not read the process output, pclose returns an error code even if the process completes successfully. The simple fix is to always read the output, even if we don't need it. Change-Id: Idaec75acbdea6a911aede04506cbd403120b3d92 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Daniel Teske --- src/androiddeployqt/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/androiddeployqt/main.cpp b/src/androiddeployqt/main.cpp index da4807b..454ad31 100644 --- a/src/androiddeployqt/main.cpp +++ b/src/androiddeployqt/main.cpp @@ -54,6 +54,8 @@ #include #include +static const bool mustReadOutputAnyway = true; // pclose seems to return the wrong error code unless we read the output + void deleteRecursively(const QString &dirName) { QDir dir(dirName); @@ -1560,10 +1562,11 @@ bool uninstallApk(const Options &options) if (adbCommand == 0) return false; - if (options.verbose) { + if (options.verbose || mustReadOutputAnyway) { char buffer[512]; while (fgets(buffer, sizeof(buffer), adbCommand) != 0) - fprintf(stdout, "%s", buffer); + if (options.verbose) + fprintf(stdout, "%s", buffer); } int returnCode = pclose(adbCommand); @@ -1604,10 +1607,11 @@ bool installApk(const Options &options) if (adbCommand == 0) return false; - if (options.verbose) { + if (options.verbose || mustReadOutputAnyway) { char buffer[512]; while (fgets(buffer, sizeof(buffer), adbCommand) != 0) - fprintf(stdout, "%s", buffer); + if (options.verbose) + fprintf(stdout, "%s", buffer); } int returnCode = pclose(adbCommand); -- 2.7.4