summaryrefslogtreecommitdiff
path: root/yaksh/base_evaluator.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-04-27 17:28:44 +0530
committerGitHub2017-04-27 17:28:44 +0530
commita67f8597da19527669b596fab08083a18c7e1fcc (patch)
tree26484d05a23223df13aabb42fe674ce759e09187 /yaksh/base_evaluator.py
parentea9e60c47b763515b324aa507da06a1e91c488c6 (diff)
parent4a8f9a117f6a784fe722b8b381368c41be86024a (diff)
downloadonline_test-a67f8597da19527669b596fab08083a18c7e1fcc.tar.gz
online_test-a67f8597da19527669b596fab08083a18c7e1fcc.tar.bz2
online_test-a67f8597da19527669b596fab08083a18c7e1fcc.zip
Merge pull request #274 from maheshgudi/kill_stray_processes
Kill stray processes
Diffstat (limited to 'yaksh/base_evaluator.py')
-rw-r--r--yaksh/base_evaluator.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/yaksh/base_evaluator.py b/yaksh/base_evaluator.py
index 071008f..e702f68 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.SIGKILL)
# Re-raise exception.
raise
return proc, stdout.decode('utf-8'), stderr.decode('utf-8')