1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-31 00:39:46 +00:00

target/ssh: Ensure exit code set for commands

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.

(From OE-Core rev: 3924e94214b5135369be2551d54fb92097d35e95)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2023-07-28 11:16:08 +01:00
parent 10ab0949a1
commit 269479f6f4
+3
View File
@@ -265,6 +265,7 @@ def SSHCall(command, logger, timeout=None, **opts):
time.sleep(5) time.sleep(5)
try: try:
process.kill() process.kill()
process.wait()
except OSError: except OSError:
logger.debug('OSError when killing process') logger.debug('OSError when killing process')
pass pass
@@ -287,6 +288,7 @@ def SSHCall(command, logger, timeout=None, **opts):
except TimeoutExpired: except TimeoutExpired:
try: try:
process.kill() process.kill()
process.wait()
except OSError: except OSError:
logger.debug('OSError') logger.debug('OSError')
pass pass
@@ -316,6 +318,7 @@ def SSHCall(command, logger, timeout=None, **opts):
# whilst running and ensure we don't leave a process behind. # whilst running and ensure we don't leave a process behind.
if process.poll() is None: if process.poll() is None:
process.kill() process.kill()
process.wait()
logger.debug('Something went wrong, killing SSH process') logger.debug('Something went wrong, killing SSH process')
raise raise