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:47:00 +0000
commit444863e78b041609c0c704053e0e98f2a5c38714 (patch)
tree1ca741ff6efeeb44f497e9069df9ced0b5d3c853 /meta/lib
parentcfc9e808531caffe1a420dae464ad88d55ae3840 (diff)
downloadpoky-444863e78b041609c0c704053e0e98f2a5c38714.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: b228cdf9d4b00411d772a7b605566d33a3a1b82b) 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 6a85f57e49..c68974f25c 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -538,10 +538,13 @@ class QemuRunner:
538 except OSError as e: 538 except OSError as e:
539 if e.errno != errno.ESRCH: 539 if e.errno != errno.ESRCH:
540 raise 540 raise
541 endtime = time.time() + self.runqemutime 541 try:
542 while self.runqemu.poll() is None and time.time() < endtime: 542 outs, errs = self.runqemu.communicate(timeout = self.runqemutime)
543 time.sleep(1) 543 if outs:
544 if self.runqemu.poll() is None: 544 self.logger.info("Output from runqemu:\n%s", outs.decode("utf-8"))
545 if errs:
546 self.logger.info("Stderr from runqemu:\n%s", errs.decode("utf-8"))
547 except TimeoutExpired:
545 self.logger.debug("Sending SIGKILL to runqemu") 548 self.logger.debug("Sending SIGKILL to runqemu")
546 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) 549 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL)
547 if not self.runqemu.stdout.closed: 550 if not self.runqemu.stdout.closed: