diff options
author | 2020-11-20 22:29:47 +0100 | |
---|---|---|
committer | 2020-11-20 22:40:24 +0100 | |
commit | 18ab777eef3045421f4df3b127079833a8c3cbe5 (patch) | |
tree | 63ce337e55ed87908ab3ec525f1ca231b8759b51 | |
parent | Increase number of characters in each read chunk (diff) |
Use SIGKILL instead of SIGTERM to terminate NsJail
This new behavior matches how other limiters terminate the subprocess,
resulting in a more consistency in the front-end for the end users as
well.
-rw-r--r-- | snekbox/nsjail.py | 6 | ||||
-rw-r--r-- | tests/test_nsjail.py | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py index a1695a5..6fc0343 100644 --- a/snekbox/nsjail.py +++ b/snekbox/nsjail.py @@ -112,7 +112,7 @@ class NsJail: The aim of this function is to limit the size of the output received from NsJail to prevent container from claiming too much memory. If the output received from STDOUT goes over the OUTPUT_MAX limit, the NsJail subprocess - is asked to terminate with a SIGTERM. + is asked to terminate with a SIGKILL. Once the subprocess has exited, either naturally or because it was terminated, the output up to that point is returned as a string. @@ -127,8 +127,8 @@ class NsJail: output.append(chars) if output_size > OUTPUT_MAX: - # Ask NsJail to terminate as we've gone over the output limit. - nsjail.terminate() + # Terminate the NsJail subprocess with SIGKILL. + nsjail.kill() break # Ensure that we wait for the NsJail subprocess to terminate. diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index 852be4b..4a040e7 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -182,4 +182,4 @@ class NsJailTests(unittest.TestCase): """).strip() result = self.nsjail.python3(stdout_flood) - self.assertEqual(result.returncode, 143) + self.assertEqual(result.returncode, -9) |