commit fb46b3a1ee642b66b9712c6f376f543c47a2695e
Author: Enrico Forestieri <for...@lyx.org>
Date:   Wed Aug 17 22:58:13 2016 +0200

    Fix exit code from runCommand on Windows
    
    On Windows, runCommand has never returned the exit code of the
    spawned process but the result of correctly closing the input handle.
    
    Fixes #10327
---
 src/support/filetools.cpp |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp
index fcb95fa..12457cb 100644
--- a/src/support/filetools.cpp
+++ b/src/support/filetools.cpp
@@ -1071,10 +1071,14 @@ cmd_ret const runCommand(string const & cmd)
 
 #if defined (_WIN32)
        WaitForSingleObject(process.hProcess, INFINITE);
+       DWORD pret;
+       if (!GetExitCodeProcess(process.hProcess, &pret))
+               pret = -1;
        if (!infile.empty())
                CloseHandle(startup.hStdInput);
        CloseHandle(process.hProcess);
-       int const pret = fclose(inf);
+       if (fclose(inf) != 0)
+               pret = -1;
 #elif defined (HAVE_PCLOSE)
        int const pret = pclose(inf);
 #elif defined (HAVE__PCLOSE)

Reply via email to