diff options
author | Alexander Kanavin <alex.kanavin@gmail.com> | 2023-01-30 23:11:25 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-02-24 16:41:42 +0000 |
commit | 59bfcd7299cd5e45a5cae976864c530ced2de6bd (patch) | |
tree | 05407bc3e53a8b838c205df5418ef7145c26aa59 | |
parent | c3fb76fc720babb16fe7042afe8eb36b535e14ac (diff) | |
download | poky-59bfcd7299cd5e45a5cae976864c530ced2de6bd.tar.gz |
oeqa/qemurunner: do not use Popen.poll() when terminating runqemu with a signal
This does not actually guarantee that the child runqemu process has completely exited:
poll() may return prematurely while the SIGTERM handler in runqemu is still running.
This thwarts the rest of the processing, and may terminate the handler before
it completes.
Use Popen.communicate() instead: this is what python documentation recommends as well:
https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate
(From OE-Core rev: 3793662bcfdab230d7b98bde2bc6757949b0aca0)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit cd3e55606c427287f37585c5d7cde936471e52f4)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index de0dff3ff0..c84d299a80 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -432,10 +432,13 @@ class QemuRunner: | |||
432 | except OSError as e: | 432 | except OSError as e: |
433 | if e.errno != errno.ESRCH: | 433 | if e.errno != errno.ESRCH: |
434 | raise | 434 | raise |
435 | endtime = time.time() + self.runqemutime | 435 | try: |
436 | while self.runqemu.poll() is None and time.time() < endtime: | 436 | outs, errs = self.runqemu.communicate(timeout = self.runqemutime) |
437 | time.sleep(1) | 437 | if outs: |
438 | if self.runqemu.poll() is None: | 438 | self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8")) |
439 | if errs: | ||
440 | self.logger.info("Stderr from runqemu:\n%s", errs.decode("utf-8")) | ||
441 | except TimeoutExpired: | ||
439 | self.logger.debug("Sending SIGKILL to runqemu") | 442 | self.logger.debug("Sending SIGKILL to runqemu") |
440 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) | 443 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) |
441 | if not self.runqemu.stdout.closed: | 444 | if not self.runqemu.stdout.closed: |