From c691f214a4986c9c0a8f6eef899981de0072186c Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 21 Sep 2023 15:34:01 +0200 Subject: [PATCH] channel: subprocess: Kill unresponsive subprocesses --- tbot/machine/channel/subprocess.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tbot/machine/channel/subprocess.py b/tbot/machine/channel/subprocess.py index 8052ab09..733d0141 100644 --- a/tbot/machine/channel/subprocess.py +++ b/tbot/machine/channel/subprocess.py @@ -104,7 +104,11 @@ def close(self) -> None: self.p.terminate() os.close(self.pty_slave) os.close(self.pty_master) - self.p.wait() + try: + self.p.communicate(timeout=10) + except subprocess.TimeoutExpired: + self.p.kill() + self.p.communicate() # Wait for all processes in the session to end. Most of the time # this will return immediately, but in some cases (eg. a serial session