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, )