From fb73cabb4a601a8172d6de653851c4a348b6abc1 Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Fri, 9 Oct 2015 20:39:49 -0400 Subject: grs/Execute.py: refactor signalexit(). --- grs/Execute.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'grs') diff --git a/grs/Execute.py b/grs/Execute.py index 3afbecc..0690e8e 100644 --- a/grs/Execute.py +++ b/grs/Execute.py @@ -44,17 +44,9 @@ class Execute(): """ def signalexit(): pid = os.getpid() - _file.write('SENDING SIGTERM to pid = %d\n' % pid) - _file.close() - 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) - except ProcessLookupError: - pass + while True: + os.kill(pid, signal.SIGTERM) + time.sleep(2.0) if shell: args = cmd @@ -82,11 +74,15 @@ class Execute(): if _rc: _file.write('EXIT CODE: %d\n' % _rc) if not failok: + _file.write('SENDING SIGTERM to pid = %d\n' % pid) + _file.close() signalexit() if timed_out: _file.write('TIMEOUT ERROR: %s\n' % cmd) if not failok: + _file.write('SENDING SIGTERM to pid = %d\n' % pid) + _file.close() signalexit() # Only close a logfile, don't close sys.stderr! -- cgit v1.2.3