diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-09-25 23:22:08 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | dbb06eac9bae1b8dbc50275b66c975da09b1d09a (patch) | |
tree | 4cfa3cc326a11aa8cd8b7ff83d8afb1b2754f150 /src/Exec.cpp | |
parent | c4d1491af938a12a0167dae4fd3ea8f1810c752a (diff) |
Fix build with msvc (windows)
Fix freeze when sub process (exec) returns a lot of data (in stdout)
Diffstat (limited to 'src/Exec.cpp')
-rw-r--r-- | src/Exec.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
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); |