From ab830b19ee0de2477e4a6efa704820dba69e59c0 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 3 Mar 2025 13:13:31 +0000 Subject: 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 --- meta/lib/oeqa/utils/qemurunner.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'meta/lib') 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: self.monitorpipe = os.fdopen(w, "w") else: # child process - os.setpgrp() - os.close(w) - r = os.fdopen(r) - x = r.read() - os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) - os._exit(0) + try: + os.setpgrp() + os.close(w) + r = os.fdopen(r) + x = r.read() + os.killpg(os.getpgid(self.runqemu.pid), signal.SIGTERM) + finally: + # We must exit under all circumstances + os._exit(0) self.logger.debug("runqemu started, pid is %s" % self.runqemu.pid) self.logger.debug("waiting at most %d seconds for qemu pid (%s)" % -- cgit v1.2.3-54-g00ecf