You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix infinite hang in wait_for_process_to_die() on Windows
The ninja generator uses wait_for_process_to_die() to wait for a
previous scons daemon process to terminate. It previously had 3
separate implemementations: one using psutil if that module was not
available, plus a fallback implementation for Windows, and one for
non-Windows platforms.
I was encountering problems with the fallback implementation on Windows
hanging forever, and not being interruptible even with Ctrl-C.
Apparently the win32 OpenProcess() function can return a valid process
handle even for already terminated processes.
This change adds an extra call to GetExitCodeProcess() to avoid
infinitely looping if the process has in fact already exited. I also
added a timeout so that this function will eventually fail rather than
hanging forever if a process does not exit.
I also removed the psutil implementation: it seemed simpler to me to
avoid having multiple separate implementations with different behaviors.
This appeared to be the only place in scons that depends on psutil
outside of tests. Also note that this wait_for_process_to_die()
function is only used by the ninja tool.
I have added unit tests checking the behavior of
wait_for_process_to_die(). Without the `GetExitCodeProcess()` check
added by this PR, the simple code in
`test_wait_for_process_to_die_success()` would hang forever.
0 commit comments