Skip to content

Commit 673ad9e

Browse files
authored
Fix bug in interactrive (#285)
1 parent bbd8fca commit 673ad9e

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

src/sinol_make/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from sinol_make.task_type.interactive import InteractiveTaskType # noqa
1313

1414

15-
__version__ = "1.9.6"
15+
__version__ = "1.9.7"
1616

1717

1818
def configure_parsers():

src/sinol_make/executors/sio2jail.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,29 @@ def __init__(self, sio2jail_path):
1717

1818
def _wrap_command(self, command: List[str], result_file_path: str, time_limit: int, memory_limit: int) -> List[str]:
1919
# see: https://github.com/sio2project/sioworkers/blob/738aa7a4e93216b0900ca128d6d48d40cd38bc1e/sio/workers/executors.py#L608
20-
return [f'"{self.sio2jail_path}"', '--mount-namespace', 'off', '--pid-namespace', 'off', '--uts-namespace',
20+
return [f'"{self.sio2jail_path}"', '-f', '3', '--mount-namespace', 'off', '--pid-namespace', 'off', '--uts-namespace',
2121
'off', '--ipc-namespace', 'off', '--net-namespace', 'off', '--capability-drop', 'off',
2222
'--user-namespace', 'off', '--instruction-count-limit', f'{int(2 * time_limit)}M',
2323
'--rtimelimit', f'{int(16 * time_limit + 1000)}ms', '--memory-limit', f'{int(memory_limit)}K',
24-
'--output-limit', '51200K', '--output', 'oiaug', '--stderr', '--'] + command
24+
'--output-limit', '51200K', '--output', 'oiaug', '--stderr', '--'] + command + \
25+
['3>', f'"{result_file_path}"']
2526

2627
def _execute(self, cmdline: str, time_limit: int, hard_time_limit: int, memory_limit: int,
2728
result_file_path: str, executable: str, execution_dir: str, stdin: int, stdout: int,
2829
stderr: Union[None, int], fds_to_close: Union[None, List[int]],
2930
*args, **kwargs) -> Tuple[bool, bool, int, List[str]]:
3031
env = os.environ.copy()
3132
env['UNDER_SIO2JAIL'] = "1"
32-
with open(result_file_path, "w") as result_file:
33-
try:
34-
process = subprocess.Popen(cmdline, *args, shell=True, stdin=stdin, stdout=stdout, env=env,
35-
stderr=result_file, preexec_fn=os.setpgrp, cwd=execution_dir, **kwargs)
36-
except TypeError as e:
37-
print(util.error(f"Invalid command: `{cmdline}`"))
38-
raise e
39-
if fds_to_close is not None:
40-
for fd in fds_to_close:
41-
os.close(fd)
42-
process.wait()
33+
try:
34+
process = subprocess.Popen(cmdline, *args, shell=True, stdin=stdin, stdout=stdout, env=env,
35+
stderr=subprocess.DEVNULL, preexec_fn=os.setpgrp, cwd=execution_dir, **kwargs)
36+
except TypeError as e:
37+
print(util.error(f"Invalid command: `{cmdline}`"))
38+
raise e
39+
if fds_to_close is not None:
40+
for fd in fds_to_close:
41+
os.close(fd)
42+
process.wait()
4343

4444
return False, False, 0, []
4545

src/sinol_make/task_type/interactive.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,15 @@ def _fill_result(self, result: ExecutionResult, iresult: ExecutionResult, intera
105105
sol_sig = result.ExitSignal
106106
inter_sig = iresult.ExitSignal
107107

108-
if interactor_output[0] != '':
108+
if result.Status is not None and result.Status != Status.OK and sol_sig != signal.SIGPIPE:
109+
return
110+
elif interactor_output[0] != '':
109111
if sol_sig == signal.SIGPIPE:
110112
result.Status = Status.WA
111113
if interactor_output[1]:
112114
result.Comment = interactor_output[1]
113115
result.Points = 0
116+
result.Error = None
114117
else:
115118
try:
116119
ok, points, comment = self._parse_checker_output(interactor_output)
@@ -133,8 +136,6 @@ def _fill_result(self, result: ExecutionResult, iresult: ExecutionResult, intera
133136
f"Interactor stderr: {iresult.Stderr}. "
134137
f"Interactor output: {interactor_output}")
135138
result.Fail = True
136-
elif result.Status is not None and result.Status != Status.OK and sol_sig != signal.SIGPIPE:
137-
return
138139
elif inter_sig == signal.SIGPIPE:
139140
result.Status = Status.WA
140141
result.Comment = "Solution exited prematurely"

0 commit comments

Comments
 (0)