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>
time.sleep(5)
try:
process.kill()
+ process.wait()
except OSError:
logger.debug('OSError when killing process')
pass
except TimeoutExpired:
try:
process.kill()
+ process.wait()
except OSError:
logger.debug('OSError')
pass
# 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