From 8b42e0ec09e1d382c88b0763cb09ae9b5bf1de39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Wed, 27 Jan 2021 11:44:34 +0100 Subject: [PATCH] Clean up zombie processes and timeout at 5 --- runall.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/runall.py b/runall.py index 691086b..b29cdab 100644 --- a/runall.py +++ b/runall.py @@ -6,7 +6,15 @@ chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'( def check_pair(script, instr, outstr): result = subprocess.run( - ["/usr/bin/env", "bash", "-c", script], + [ + "/usr/bin/env", "bash", "-c", + ";\n".join(( + # Cleanup child processes on exit + "trap 'kill -9 $(jobs -p)' SIGINT SIGTERM EXIT", + script, + )) + ], + timeout=5, input=instr.encode(), capture_output=True, )