diff options
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); |