]> git.lyx.org Git - features.git/commitdiff
Further amend fb7b7e52
authorEnrico Forestieri <forenr@lyx.org>
Sun, 11 Dec 2022 13:58:42 +0000 (14:58 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 11 Dec 2022 14:06:22 +0000 (15:06 +0100)
This restores the previous behavior of runCommand().
When the child process could not be properly terminated the
error "RunCommand: could not terminate child process" was being
issued. However, in fb7b7e52 there was a misinterpretation
between this condition and the exit status of the child and
these two different errors were mixed up. They are now
disentangled again.

src/support/filetools.cpp

index f7460ce1886fa7435715855cc932627628e63b3d..6e9cf34fae4e908681a4a4797a7ec871e4fa52ff 100644 (file)
@@ -1141,11 +1141,13 @@ cmd_ret const runCommand(string const & cmd)
        DWORD pret;
        BOOL success = GetExitCodeProcess(process.hProcess, &pret);
        bool valid = (pret == 0) && success;
+       if (!success)
+               pret = -1;
        if (!infile.empty())
                CloseHandle(startup.hStdInput);
        CloseHandle(process.hProcess);
        if (fclose(inf) != 0)
-               valid = false;
+               pret = -1;
 #elif defined (HAVE_PCLOSE)
        int const pret = pclose(inf);
        bool const valid = (WEXITSTATUS(pret) == 0);
@@ -1156,7 +1158,7 @@ cmd_ret const runCommand(string const & cmd)
 #error No pclose() function.
 #endif
 
-       if (!valid)
+       if (pret == -1)
                perror("RunCommand: could not terminate child process");
 
        return { valid, result };