From dbb06eac9bae1b8dbc50275b66c975da09b1d09a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 25 Sep 2018 23:22:08 +0200 Subject: Fix build with msvc (windows) Fix freeze when sub process (exec) returns a lot of data (in stdout) --- src/Exec.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Exec.cpp') diff --git a/src/Exec.cpp b/src/Exec.cpp index 6c1a72e..659d812 100644 --- a/src/Exec.cpp +++ b/src/Exec.cpp @@ -99,13 +99,8 @@ namespace sibs if (!CreateProcessW(nullptr, (LPWSTR)cmdNonConst.data(), nullptr, nullptr, TRUE, 0, nullptr, nullptr, &siStartInfo, &piProcInfo)) goto cleanupAndExit; - WaitForSingleObject(piProcInfo.hProcess, INFINITE); - GetExitCodeProcess(piProcInfo.hProcess, &exitCode); - CloseHandle(piProcInfo.hProcess); - CloseHandle(piProcInfo.hThread); CloseHandle(childStdoutHandle); childStdoutHandle = nullptr; - DWORD bytesRead; CHAR buffer[BUFSIZE]; while (true) @@ -119,6 +114,11 @@ namespace sibs printf("%.*s", bytesRead, buffer); } + WaitForSingleObject(piProcInfo.hProcess, INFINITE); + GetExitCodeProcess(piProcInfo.hProcess, &exitCode); + CloseHandle(piProcInfo.hProcess); + CloseHandle(piProcInfo.hThread); + { ExecResult execResult; execResult.execStdout = move(execStdout); -- cgit v1.2.3