Revert r235177 as the Handle is used to fail GetExitCodeProcess on purpose.

Avoid double closing of the handle by testing GetLastErr for 
ERROR_INVALID_HANDLE and not calling CloseHandle(PI.ProcessHandle) then.

llvm-svn: 235184
This commit is contained in:
Yaron Keren 2015-04-17 12:11:15 +00:00
parent bb60cfb5c4
commit 97de57343a
1 changed files with 3 additions and 1 deletions

View File

@ -423,6 +423,7 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
return WaitResult;
}
WaitForSingleObject(PI.ProcessHandle, INFINITE);
CloseHandle(PI.ProcessHandle);
} else {
// Non-blocking wait.
return ProcessInfo();
@ -433,7 +434,8 @@ ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
DWORD status;
BOOL rc = GetExitCodeProcess(PI.ProcessHandle, &status);
DWORD err = GetLastError();
CloseHandle(PI.ProcessHandle);
if (err != ERROR_INVALID_HANDLE)
CloseHandle(PI.ProcessHandle);
if (!rc) {
SetLastError(err);