From: Ondrej Lichtner <olichtne(a)redhat.com>
The kill command on a slave job should target the whole process group of
the child, since the Job process (a python process running LNST code)
can launch additional applications (e.g. iperf server) that should get
killed as well.
I also added some debug logging in case the job finished before the kill
method was called.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Slave/Job.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lnst/Slave/Job.py b/lnst/Slave/Job.py
index bf159a6..36e5160 100644
--- a/lnst/Slave/Job.py
+++ b/lnst/Slave/Job.py
@@ -49,7 +49,7 @@ class JobContext(object):
def _kill_all_jobs(self):
for id in self._dict:
- self._dict[id].kill(signal=signal.SIGKILL)
+ self._dict[id].kill(sig=signal.SIGKILL)
def cleanup(self):
logging.debug("Cleaning up leftover processes.")
@@ -124,10 +124,11 @@ class Job(object):
def kill(self, signal=signal.SIGKILL):
if self._finished:
+ logging.debug("Job finished before sending the signal")
return True
try:
logging.debug("Sending signal %s to pid %d" % (signal, self._pid))
- os.kill(self._pid, signal)
+ os.killpg(self._pid, signal)
return True
except OSError as exc:
logging.error(str(exc))
--
2.17.0