diff --git a/avocado/utils/process.py b/avocado/utils/process.py index 55f94766ed2645a966688ba607a75850916ca82b..a4943e958f29febb08ed0de141b9a46366002f49 100644 --- a/avocado/utils/process.py +++ b/avocado/utils/process.py @@ -563,21 +563,19 @@ class SubProcess(object): :rtype: A :class:`CmdResult` instance. """ self._init_subprocess() - start_time = time.time() if timeout is None: self.wait() - - if timeout > 0.0: - while time.time() - start_time < timeout: - self.poll() - if self.result.exit_status is not None: - break + elif timeout > 0.0: + timer = threading.Timer(timeout, self.send_signal, [sig]) + try: + timer.start() + self.wait() + finally: + timer.cancel() if self.result.exit_status is None: - internal_timeout = 1.0 - self.send_signal(sig) - stop_time = time.time() + internal_timeout + stop_time = time.time() + 1 while time.time() < stop_time: self.poll() if self.result.exit_status is not None: