diff mbox series

[kirkstone,34/36] target/ssh: Ensure exit code set for commands

Message ID c70b05ea667e7bd280470b0b6ca10efb0f648e0f.1692799745.git.steve@sakoman.com
State Accepted, archived
Commit c70b05ea667e7bd280470b0b6ca10efb0f648e0f
Headers show
Series [kirkstone,01/36] glib-2.0: Fix CVE-2023-32665 | expand

Commit Message

Steve Sakoman Aug. 23, 2023, 2:36 p.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

As spotted by Joshua Watt, the returncode isn't set until .poll() or .wait()
is called so we need to call this after the .kill() call.

This fixes return code reporting so that timeouts for example now return an
exit code when they didn't before.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 3924e94214b5135369be2551d54fb92097d35e95)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
---
 meta/lib/oeqa/core/target/ssh.py | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py
index 7c206ff105..69fdc146f0 100644
--- a/meta/lib/oeqa/core/target/ssh.py
+++ b/meta/lib/oeqa/core/target/ssh.py
@@ -262,6 +262,7 @@  def SSHCall(command, logger, timeout=None, **opts):
                 time.sleep(5)
                 try:
                     process.kill()
+                    process.wait()
                 except OSError:
                     logger.debug('OSError when killing process')
                     pass
@@ -284,6 +285,7 @@  def SSHCall(command, logger, timeout=None, **opts):
             except TimeoutExpired:
                 try:
                     process.kill()
+                    process.wait()
                 except OSError:
                     logger.debug('OSError')
                     pass
@@ -313,6 +315,7 @@  def SSHCall(command, logger, timeout=None, **opts):
         # whilst running and ensure we don't leave a process behind.
         if process.poll() is None:
             process.kill()
+            process.wait()
         logger.debug('Something went wrong, killing SSH process')
         raise