Clean up zombie processes and timeout at 5

This commit is contained in:
Mattéo Delabre 2021-01-27 11:44:34 +01:00
parent d0f3f0ba31
commit 8b42e0ec09
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 9 additions and 1 deletions

View File

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