aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grs/Execute.py23
-rw-r--r--grs/Interpret.py18
2 files changed, 10 insertions, 31 deletions
diff --git a/grs/Execute.py b/grs/Execute.py
index 0e70221..7b0e5a2 100644
--- a/grs/Execute.py
+++ b/grs/Execute.py
@@ -42,12 +42,6 @@ class Execute():
logfile - A file to log output to. If logfile = None, then we log
to sys.stdout.
"""
- def signalexit():
- pid = os.getpid()
- while True:
- os.kill(pid, signal.SIGTERM)
- time.sleep(2.0)
-
if shell:
args = cmd
else:
@@ -71,19 +65,16 @@ class Execute():
if not timed_out:
# _rc = None if we had a timeout
_rc = proc.returncode
- if _rc:
- _file.write('EXIT CODE: %d\n' % _rc)
- if not failok:
- _file.write('SENDING SIGTERM\n')
- _file.close()
- signalexit()
+ _file.write('EXIT CODE: %d\n' % _rc)
if timed_out:
_file.write('TIMEOUT ERROR: %s\n' % cmd)
- if not failok:
- _file.write('SENDING SIGTERM\n')
- _file.close()
- signalexit()
+
+ if not failok and ( _rc != 0 or timed_out):
+ pid = os.getpid()
+ _file.write('SENDING SIGTERM: %s\n' % pid)
+ _file.close()
+ os.kill(pid, signal.SIGTERM)
# Only close a logfile, don't close sys.stderr!
if logfile:
diff --git a/grs/Interpret.py b/grs/Interpret.py
index 3e2c408..5624fd4 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -64,12 +64,7 @@ class Interpret(Daemon):
if mypid == pid:
continue
try:
- for i in range(10):
- os.kill(pid, signal.SIGTERM)
- time.sleep(0.2)
- while True:
- os.kill(pid, signal.SIGKILL)
- time.sleep(0.2)
+ os.kill(pid, signal.SIGKILL)
except ProcessLookupError:
pass
try:
@@ -79,13 +74,6 @@ class Interpret(Daemon):
sys.exit(signum + 128)
- def signalexit():
- pid = os.getpid()
- while True:
- os.kill(pid, signal.SIGTERM)
- time.sleep(2.0)
-
-
def semantic_action(_line, objs, nargs, func, *args):
""" Execute the directive """
err = None
@@ -104,7 +92,7 @@ class Interpret(Daemon):
_lo.log('Bad command: %s' % _line)
_lo.log('Error message: %s' % err)
_lo.log('SENDING SIGTERM\n')
- signalexit()
+ os.kill(os.getpid(), signal.SIGTERM)
def stampit(progress):
@@ -262,7 +250,7 @@ class Interpret(Daemon):
_lo.log('Bad command: %s' % _line)
_lo.log('Unknown verb: %s' % verb)
_lo.log('SENDING SIGTERM\n')
- signalexit()
+ os.kill(os.getpid(), signal.SIGTERM)
stampit(progress)