diff options
author | mahesh | 2017-04-04 13:00:41 +0530 |
---|---|---|
committer | mahesh | 2017-04-04 13:00:41 +0530 |
commit | a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb (patch) | |
tree | 0c0696c6d071efb7569e425f46c3df2cbb63f6f2 /yaksh/base_evaluator.py | |
parent | 734ad94d177be8ad400eb6f97e98612ce099e56a (diff) | |
download | online_test-a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb.tar.gz online_test-a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb.tar.bz2 online_test-a9d7b48b6a5a79bf619500463d89f03e8ca1b7bb.zip |
Kills stray processes in code, hook and stdio evaluator
Diffstat (limited to 'yaksh/base_evaluator.py')
-rw-r--r-- | yaksh/base_evaluator.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/yaksh/base_evaluator.py b/yaksh/base_evaluator.py index 071008f..653aef0 100644 --- a/yaksh/base_evaluator.py +++ b/yaksh/base_evaluator.py @@ -7,6 +7,7 @@ from os.path import join, isfile from os.path import isdir, dirname, abspath, join, isfile, exists import subprocess import stat +import signal # Local imports @@ -30,11 +31,11 @@ class BaseEvaluator(object): stdout and stderr. """ try: - proc = subprocess.Popen(cmd_args, *args, **kw) + proc = subprocess.Popen(cmd_args,preexec_fn=os.setpgrp, *args, **kw) stdout, stderr = proc.communicate() except TimeoutException: # Runaway code, so kill it. - proc.kill() + os.killpg(os.getpgid(proc.pid), signal.SIGTERM) # Re-raise exception. raise return proc, stdout.decode('utf-8'), stderr.decode('utf-8') |