summaryrefslogtreecommitdiff
path: root/lib/Support/Windows/Program.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Support/Windows/Program.inc')
-rw-r--r--lib/Support/Windows/Program.inc3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc
index c3700774514c3..75685de455476 100644
--- a/lib/Support/Windows/Program.inc
+++ b/lib/Support/Windows/Program.inc
@@ -434,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);