diff --git a/avocado/utils/process.py b/avocado/utils/process.py index 545accf7b9fd20e58e3900faa49838f341f2a727..f47d16f5f508c80d4a21deb1e2629d54ab8d4806 100644 --- a/avocado/utils/process.py +++ b/avocado/utils/process.py @@ -203,21 +203,23 @@ class SubProcess(object): """ Send a :attr:`signal.SIGTERM` to the process. """ - try: - os.kill(self.sp.pid, signal.SIGTERM) - except: - pass + self.send_signal(signal.SIGTERM) def kill(self): """ Send a :attr:`signal.SIGKILL` to the process. """ - try: - os.kill(self.sp.pid, signal.SIGKILL) - except: - pass + self.send_signal(signal.SIGKILL) - def wait(self, timeout=None): + def send_signal(self, sig): + """ + Send the specified signal to the process. + + :param sig: Signal to send. + """ + self.sp.send_signal(sig) + + def wait(self, timeout=None, sig=signal.SIGTERM): """ Wait for the process to end, filling and returning the result attr. @@ -243,7 +245,7 @@ class SubProcess(object): timeout = 1 if self.result.exit_status is None: - self.terminate() + self.send_signal(sig) # Timeout here should be 1 second (see comment above) stop_time = time.time() + timeout while time.time() < stop_time: