]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
target/ssh: Ensure exit code set for commands
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 28 Jul 2023 10:16:08 +0000 (11:16 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 29 Jul 2023 07:25:07 +0000 (08:25 +0100)
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>
meta/lib/oeqa/core/target/ssh.py

index 243e45dd99e1e9fa77c24f3b9b4a48f064b2e9b1..72ed1adbf89863904508870e1f848511846231ca 100644 (file)
@@ -265,6 +265,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
@@ -287,6 +288,7 @@ def SSHCall(command, logger, timeout=None, **opts):
             except TimeoutExpired:
                 try:
                     process.kill()
+                    process.wait()
                 except OSError:
                     logger.debug('OSError')
                     pass
@@ -316,6 +318,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