diff --git a/tests/fuzz/runner.py b/tests/fuzz/runner.py index 512a20e58c5..8e05625a6d9 100644 --- a/tests/fuzz/runner.py +++ b/tests/fuzz/runner.py @@ -58,12 +58,12 @@ def process_error(error: str): def kill_fuzzer(fuzzer: str): - p = subprocess.Popen(["ps", "-A"], stdout=subprocess.PIPE) - out, err = p.communicate() - for line in out.splitlines(): - if fuzzer in line: - pid = int(line.split(None, 1)[0]) - os.kill(pid, signal.SIGKILL) + with subprocess.Popen(["ps", "-A"], stdout=subprocess.PIPE) as p + out, _ = p.communicate() + for line in out.splitlines(): + if fuzzer in line: + pid = int(line.split(None, 1)[0]) + os.kill(pid, signal.SIGKILL) def run_fuzzer(fuzzer: str, timeout: int):