Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Common/NetTestCommand.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lnst/Common/NetTestCommand.py b/lnst/Common/NetTestCommand.py index 774c26e..b64186d 100644 --- a/lnst/Common/NetTestCommand.py +++ b/lnst/Common/NetTestCommand.py @@ -188,15 +188,18 @@ class NetTestCommand: self._finished = True self._control_cmd = cmd
+ def pid_exists(self): + return os.path.exists("/proc/%d" % self._pid) + def interrupt(self, cmd): self._finished = True - if os.path.exists("/proc/%d" % self._pid): + if self.pid_exists(): logging.debug("Interrupting background command with id "%s", pid "%d"" % (self._id, self._pid)) os.killpg(os.getpgid(self._pid), signal.SIGINT) self._control_cmd = cmd
def kill(self, cmd): - if os.path.exists("/proc/%d" % self._pid): + if self.pid_exists(): if self._id: logging.debug("Killing background command with id "%s", pid "%d"" % (self._id, self._pid)) else: