mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Do not fail if process already ended
We can expect the subprocess has already ended by the time we're checking for child processes. Handle this case gracefully so that tests do not fail with an exception.
This commit is contained in:
parent
85e22d2f25
commit
7f613ac020
@ -1548,7 +1548,11 @@ def win32_kill_process_tree(pid, sig=signal.SIGTERM, include_parent=True,
|
|||||||
'''
|
'''
|
||||||
if pid == os.getpid():
|
if pid == os.getpid():
|
||||||
raise RuntimeError("I refuse to kill myself")
|
raise RuntimeError("I refuse to kill myself")
|
||||||
|
try:
|
||||||
parent = psutil.Process(pid)
|
parent = psutil.Process(pid)
|
||||||
|
except psutil.NoSuchProcess:
|
||||||
|
log.debug("PID not found alive: %d", pid)
|
||||||
|
return ([], [])
|
||||||
children = parent.children(recursive=True)
|
children = parent.children(recursive=True)
|
||||||
if include_parent:
|
if include_parent:
|
||||||
children.append(parent)
|
children.append(parent)
|
||||||
|
Loading…
Reference in New Issue
Block a user