summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/python_session.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/server/python_session.py b/server/python_session.py
index 85e1d2e..55a4812 100644
--- a/server/python_session.py
+++ b/server/python_session.py
@@ -150,12 +150,19 @@ def _interpreter(control, callback):
if retcode is None:
data = proc.stdout.read()
if data:
- # NOTE this might fail if read() stops in the middle of utf8 sequence
- text = data.decode('utf-8')
- if text:
- callback(text)
+ if len(data) > 20000:
+ proc.kill()
+ proc = None
+ callback('Child killed for talking too much.\n')
+ else:
+ # NOTE this might fail if read() stops in the middle of utf8 sequence
+ text = data.decode('utf-8')
+ if text:
+ callback(text)
else:
- if retcode == -31:
+ if retcode == -9: # killed by ulimit
+ callback('Child killed due to overconsumption.\n')
+ elif retcode == -31: # killed by seccomp
callback('Child killed due to sandbox misbehavior.\n')
else:
callback('Child exited with status "{}".\n'.format(retcode))