1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-05 18:30:50 +01:00

connection: kill spawned child subprocesses:

Subprocesses that were spawned under the same pgid were not necessarily
being terminated when the parent was terminated, allowing them to
continue running. This change explicitly kills the process group
involved.
This commit is contained in:
Jonathan Paynter 2020-08-10 17:29:02 +01:00 committed by Marc Bonnici
parent 0498017bf0
commit dc7faf46e4

View File

@ -203,11 +203,11 @@ class PopenBackgroundCommand(BackgroundCommand):
def cancel(self, kill_timeout=_KILL_TIMEOUT):
popen = self.popen
popen.send_signal(signal.SIGTERM)
os.killpg(os.getpgid(popen.pid), signal.SIGTERM)
try:
popen.wait(timeout=_KILL_TIMEOUT)
except subprocess.TimeoutExpired:
popen.kill()
os.killpg(os.getpgid(popen.pid), signal.SIGKILL)
def close(self):
self.popen.__exit__(None, None, None)