diff --git a/tests/lib/terminal.py b/tests/lib/terminal.py index de181035..e5749d57 100644 --- a/tests/lib/terminal.py +++ b/tests/lib/terminal.py @@ -5,6 +5,7 @@ import threading from time import sleep from itertools import groupby +from signal import SIGKILL import pexpect @@ -24,6 +25,7 @@ class ExpectProcess(threading.Thread): self.env = env self.buffer = [] self.child_lock = threading.Lock() + self.shutdown_event = threading.Event() def run(self): child = pexpect.spawn(self.cmd, self.args, cwd=self.cwd, env=self.env) @@ -32,7 +34,7 @@ class ExpectProcess(threading.Thread): sleep(0.5) self.child = child status = None - while status is None: + while status is None and not self.shutdown_event.is_set(): try: with self.child_lock: s = child.read_nonblocking(size=1024, timeout=0) @@ -46,6 +48,12 @@ class ExpectProcess(threading.Thread): self.vterm.push(s) self.buffer.append(s) + if status is None: + child.kill(SIGKILL) + + def kill(self): + self.shutdown_event.set() + def resize(self, rows, cols): with self.child_lock: self.rows = rows diff --git a/tests/test_in_vterm/test_tmux.py b/tests/test_in_vterm/test_tmux.py index ad7ed791..b46ce89f 100755 --- a/tests/test_in_vterm/test_tmux.py +++ b/tests/test_in_vterm/test_tmux.py @@ -306,8 +306,9 @@ def main(attempts=3): if ret is not None: return ret finally: - check_call([tmux_exe, '-S', socket_path, 'kill-server'], env=env, - cwd=VTERM_TEST_DIR) + p.kill() + p.join(10) + assert(not p.isAlive()) return main(attempts=(attempts - 1))