From 3dc2539711ee3aea52f2653ec3c3036a1b0c2a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E5=BF=83=E7=A6=BE?= Date: Thu, 11 Jun 2020 06:31:09 +0800 Subject: [PATCH] Fix multiple commands in `judging` --- dockerjudge/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dockerjudge/__init__.py b/dockerjudge/__init__.py index c08ec11..258692b 100644 --- a/dockerjudge/__init__.py +++ b/dockerjudge/__init__.py @@ -43,9 +43,13 @@ def _judge(dir, container, commands, ioput, timeout, iofile) -> (str, float): '{}/{}'.format(shlex.quote(ioput[0]), dir, iofile[0])]) result = container.exec_run(['bash', '-c', 'cd {}&&time timeout -s ' - 'KILL {} {}<{}'.format(dir, timeout, - commands[1] % '..', - iofile[0])], + 'KILL {} sh -c {}<{}'.format(dir, timeout, + shlex.quote( + commands + [1] + % '..' + ), + iofile[0])], demux=True) else: result = container.exec_run(['bash', '-c', 'cd {}&&time echo {}|'