mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1433905 - [mozprocess] Existence of _handle on Windows doesn't mean the process is still alive. r=gbrown
The assumption that when a handle is present for the process handler on Windows doesn't mean that the process is still alive. It could have already been externally killed, crashed, or closed itself. The patch makes sure to check the process exit code, and run clean-up steps if the process is already gone. Depends on D7395 Differential Revision: https://phabricator.services.mozilla.com/D7396 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4a1ba8961f
commit
0b6b3e94da
@ -202,14 +202,27 @@ class ProcessHandlerMixin(object):
|
||||
return self.returncode
|
||||
|
||||
def poll(self):
|
||||
""" Popen.poll
|
||||
Check if child process has terminated. Set and return returncode attribute.
|
||||
"""
|
||||
# If we have a handle, the process is alive
|
||||
if isWin and getattr(self, '_handle', None):
|
||||
return None
|
||||
"""Check if child process has terminated, and set returncode attribute.
|
||||
|
||||
return subprocess.Popen.poll(self)
|
||||
This method overrides the Popen.poll implementation for our custom
|
||||
process handling for Windows.
|
||||
"""
|
||||
if isWin:
|
||||
# If we have a handle, check that the process is still alive.
|
||||
if self._handle:
|
||||
returncode = winprocess.GetExitCodeProcess(self._handle)
|
||||
|
||||
# If the process doesn't exist anymore run cleanup steps
|
||||
if returncode != winprocess.STILL_ACTIVE:
|
||||
self.returncode = returncode
|
||||
self._cleanup()
|
||||
else:
|
||||
self.returncode = None
|
||||
|
||||
else:
|
||||
self.returncode = subprocess.Popen.poll(self)
|
||||
|
||||
return self.returncode
|
||||
|
||||
def wait(self):
|
||||
""" Popen.wait
|
||||
|
Loading…
x
Reference in New Issue
Block a user