Opened 5 years ago
#13110 new Bugs
cannot wait/join process to actually terminate after calling child::terminate
Reported by: | Owned by: | ||
---|---|---|---|
Milestone: | To Be Determined | Component: | process |
Version: | Boost 1.64.0 | Severity: | Problem |
Keywords: | Cc: |
Description
On Windows child::terminate() calls TerminateProcess, which is asynchronous. I need to wait for the process to actually terminate, but join()/wait() early out because a) _terminated gets set to true and b) the process handle is closed within terminate().
The Unix implementation uses waitpid() after calling kill() to wait for the process state to change, thus the behaviour is different.
From MSDN: "TerminateProcess is asynchronous; it initiates termination and returns immediately. If you need to be sure the process has terminated, call the WaitForSingleObject function with a handle to the process."
Because waiting for a process to actually terminate might take a long time I think it would be best to use a parameter to specify whether terminate() shall wait or not, and allow waiting for the process after calling terminate(). Alternatively please provide a async_terminate() and fix the Windows implementation to wait internally.