[LyX/master] Further amend fb7b7e52

Enrico Forestieri forenr at lyx.org
Sun Dec 11 13:10:18 UTC 2022


commit e18709b176daf7e7db34b89afc240a615764fe78
Author: Enrico Forestieri <forenr at lyx.org>
Date:   Sun Dec 11 14:58:42 2022 +0100

    Further amend fb7b7e52
    
    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 |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index f7460ce..6e9cf34 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -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 };


More information about the lyx-cvs mailing list