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-01 14:05:15 +0000 |
commit | 7388cb224e3dd245e5269b4037fce1a5da940455 (patch) | |
tree | a5f7f2fb553466cca88617b7df0f0146fe777bf7 /meta/lib/oeqa/utils/qemurunner.py | |
parent | da95831d91b1265ecaee5bbfaeb1caaa2c290838 (diff) | |
download | poky-7388cb224e3dd245e5269b4037fce1a5da940455.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: cd3e55606c427287f37585c5d7cde936471e52f4)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-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 b5fed6c9fe..8b893601d4 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -543,10 +543,13 @@ class QemuRunner: | |||
543 | except OSError as e: | 543 | except OSError as e: |
544 | if e.errno != errno.ESRCH: | 544 | if e.errno != errno.ESRCH: |
545 | raise | 545 | raise |
546 | endtime = time.time() + self.runqemutime | 546 | try: |
547 | while self.runqemu.poll() is None and time.time() < endtime: | 547 | outs, errs = self.runqemu.communicate(timeout = self.runqemutime) |
548 | time.sleep(1) | 548 | if outs: |
549 | if self.runqemu.poll() is None: | 549 | self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8")) |
550 | if errs: | ||
551 | self.logger.info("Stderr from runqemu:\n%s", errs.decode("utf-8")) | ||
552 | except TimeoutExpired: | ||
550 | self.logger.debug("Sending SIGKILL to runqemu") | 553 | self.logger.debug("Sending SIGKILL to runqemu") |
551 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) | 554 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) |
552 | if not self.runqemu.stdout.closed: | 555 | if not self.runqemu.stdout.closed: |