Unverified Commit 6f957bca authored by Michael Snoyman's avatar Michael Snoyman Committed by GitHub

Merge pull request #159 from Mistuke/wip/wait-for-actual-process-termination

Windows: Check if all processes really exited and released resources
parents c4487496 8cb23fd4
...@@ -903,7 +903,8 @@ waitForJobCompletion ( HANDLE hJob, HANDLE ioPort, DWORD timeout, int *pExitCode ...@@ -903,7 +903,8 @@ waitForJobCompletion ( HANDLE hJob, HANDLE ioPort, DWORD timeout, int *pExitCode
// List of events we can listen to: // List of events we can listen to:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms684141(v=vs.85).aspx // https://msdn.microsoft.com/en-us/library/windows/desktop/ms684141(v=vs.85).aspx
while (GetQueuedCompletionStatus (ioPort, &CompletionCode, while (GetQueuedCompletionStatus (ioPort, &CompletionCode,
&CompletionKey, &Overlapped, timeout)) { &CompletionKey, &Overlapped, timeout)
&& (HANDLE)CompletionKey == hJob) {
switch (CompletionCode) switch (CompletionCode)
{ {
...@@ -930,6 +931,10 @@ waitForJobCompletion ( HANDLE hJob, HANDLE ioPort, DWORD timeout, int *pExitCode ...@@ -930,6 +931,10 @@ waitForJobCompletion ( HANDLE hJob, HANDLE ioPort, DWORD timeout, int *pExitCode
maperrno(); maperrno();
return 1; return 1;
} }
// Check to see if the child has actually exited.
if (*(DWORD *)pExitCode == STILL_ACTIVE)
waitForProcess ((ProcHandle)pHwnd, pExitCode);
} }
break; break;
case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO: case JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO:
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
## Unreleased changes ## Unreleased changes
* Fix a race condition on Windows that happens when you use process jobs and one of
the child processes terminates but doesn't release its resources immediately.
Control returns to the caller too soon in this scenario. See [#159](https://github.com/haskell/process/pull/159)
## 1.6.6.0 *October 2019* ## 1.6.6.0 *October 2019*
* Fix a potential privilege escalation issue (or, more precisely, privileges * Fix a potential privilege escalation issue (or, more precisely, privileges
...@@ -29,7 +33,7 @@ ...@@ -29,7 +33,7 @@
* Bug fix: Don't leak pipes on failure * Bug fix: Don't leak pipes on failure
[#122](https://github.com/haskell/process/issues/122) [#122](https://github.com/haskell/process/issues/122)
* Expose `cleanupProcess` from `System.Process` * Expose `cleanupProcess` from `System.Process`
[#130](https://github.com/haskell/process/pull/130) [#130](https://github.com/haskell/process/pull/130)
* Drop support for GHC before 7.10.3 * Drop support for GHC before 7.10.3
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment