summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2023-01-30 23:11:25 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-02-15 21:46:56 +0000
commit58c692d246e69d35041fe0b0a1dc77512b0b02e7 (patch)
treeeb6f2717b096510f1858ff5c27a46df0094578b7 /meta/lib
parentd2c1494bbf36b6392e47ffd4a75307d29681d190 (diff)
downloadpoky-58c692d246e69d35041fe0b0a1dc77512b0b02e7.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: 88e7bac0f06d4f12cd6f078d37e4e9975871860f) 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>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index c19164e6e7..9a99859388 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -532,10 +532,13 @@ class QemuRunner:
532 except OSError as e: 532 except OSError as e:
533 if e.errno != errno.ESRCH: 533 if e.errno != errno.ESRCH:
534 raise 534 raise
535 endtime = time.time() + self.runqemutime 535 try:
536 while self.runqemu.poll() is None and time.time() < endtime: 536 outs, errs = self.runqemu.communicate(timeout = self.runqemutime)
537 time.sleep(1) 537 if outs:
538 if self.runqemu.poll() is None: 538 self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8"))
539 if errs:
540 self.logger.info("Stderr from runqemu:\n%s", errs.decode("utf-8"))
541 except TimeoutExpired:
539 self.logger.debug("Sending SIGKILL to runqemu") 542 self.logger.debug("Sending SIGKILL to runqemu")
540 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) 543 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL)
541 if not self.runqemu.stdout.closed: 544 if not self.runqemu.stdout.closed: