runqemu: check the qemu PID has been set before kill()ing it

Message ID 20211208170230.3800425-1-ross.burton@arm.com
State Accepted, archived
Commit 0f3afbd3a6a6bef668612f818517df7543c0a683
Headers show
Series runqemu: check the qemu PID has been set before kill()ing it | expand

Commit Message

Ross Burton Dec. 8, 2021, 5:02 p.m. UTC
If runqemu is killed, check that we have a valid PID for the qemu before
sending a kill() to it.

[ YOCTO #14651 ]

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 scripts/runqemu | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch

diff --git a/scripts/runqemu b/scripts/runqemu
index efb98ab9e0f..410d2a9939b 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -1593,7 +1593,8 @@  def main():
 
         def sigterm_handler(signum, frame):
             logger.info("SIGTERM received")
-            os.kill(config.qemupid, signal.SIGTERM)
+            if config.qemupid:
+                os.kill(config.qemupid, signal.SIGTERM)
             config.cleanup()
             # Deliberately ignore the return code of 'tput smam'.
             subprocess.call(["tput", "smam"])