summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-03 13:13:31 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-03-03 18:01:30 +0000
commitab830b19ee0de2477e4a6efa704820dba69e59c0 (patch)
tree61063fdced657d35cafdfef32cc10c5fcf782d9f /meta/lib
parent171da2fa9cfca4cb12455c125cd68f662bbf7f8f (diff)
downloadpoky-ab830b19ee0de2477e4a6efa704820dba69e59c0.tar.gz
qemurunner: Fix a bug with fork/exit handling
If you send this forked process a SIGTERM, it will execute all of the parent's exit code leading to two sets of console/exit output which is extremely confusing. Wrap the code in a try/finally to ensure we always call os._exit() to avoid this. I spent far too long trying to work out the crazy console output from this. (From OE-Core rev: 652e40bfae24b8e23bbf7a7f35d900d2ab8d0f92) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 04e0334914..c4db0cf038 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -267,12 +267,15 @@ class QemuRunner:
267 self.monitorpipe = os.fdopen(w, "w") 267 self.monitorpipe = os.fdopen(w, "w")
268 else: 268 else:
269 # child process 269 # child process
270 os.setpgrp() 270 try:
271 os.close(w) 271 os.setpgrp()
272 r = os.fdopen(r) 272 os.close(w)
273 x = r.read() 273 r = os.fdopen(r)
274 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) 274 x = r.read()
275 os._exit(0) 275 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM)
276 finally:
277 # We must exit under all circumstances
278 os._exit(0)
276 279
277 self.logger.debug("runqemu started, pid is %s" % self.runqemu.pid) 280 self.logger.debug("runqemu started, pid is %s" % self.runqemu.pid)
278 self.logger.debug("waiting at most %d seconds for qemu pid (%s)" % 281 self.logger.debug("waiting at most %d seconds for qemu pid (%s)" %