summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/process.py
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2019-02-27 09:50:52 +0000
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2019-03-04 06:53:51 +0000
commit0d714c976db47b971101b3d26313794b3554776a (patch)
treef8b4dc0a76942d7b5e005c1250500bc4bb999df8 /src/osmo_gsm_tester/process.py
parent20b52c1ee36f892daa1467c2cec18d894e024560 (diff)
process: Make sending signals (kill) externally visible
Diffstat (limited to 'src/osmo_gsm_tester/process.py')
-rw-r--r--src/osmo_gsm_tester/process.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/osmo_gsm_tester/process.py b/src/osmo_gsm_tester/process.py
index 1e53aba..3050f83 100644
--- a/src/osmo_gsm_tester/process.py
+++ b/src/osmo_gsm_tester/process.py
@@ -145,6 +145,12 @@ class Process(log.Origin):
def send_signal(self, sig):
os.kill(self.process_obj.pid, sig)
+ def kill(self, sig):
+ """Kills the process with the given signal and remembers it."""
+ self.log('Terminating (%s)' % sig.name)
+ self.send_signal(sig)
+ self.killed = sig
+
def terminate(self):
if self.process_obj is None:
return
@@ -153,23 +159,17 @@ class Process(log.Origin):
while True:
# first try SIGINT to allow stdout+stderr flushing
- self.log('Terminating (SIGINT)')
- self.send_signal(signal.SIGINT)
- self.killed = signal.SIGINT
+ self.kill(signal.SIGINT)
if self._poll_termination():
break
# SIGTERM maybe?
- self.log('Terminating (SIGTERM)')
- self.send_signal(signal.SIGTERM)
- self.killed = signal.SIGTERM
+ self.kill(signal.SIGTERM)
if self._poll_termination():
break
# out of patience
- self.log('Terminating (SIGKILL)')
- self.send_signal(signal.SIGKILL)
- self.killed = signal.SIGKILL
+ self.kill(signal.SIGKILL)
break;
self.process_obj.wait()