diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-07-29 09:00:49 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-07-30 07:54:44 +0100 |
commit | c2d0ac3f0d8de681b28e0aca6dc41e93f4ca0540 (patch) | |
tree | 852e3862af0dbbe5c7001e022180986f9ca99db4 /meta/lib/oeqa/core/target | |
parent | de9508dbd3270ad3221a5b6ae47ee3d4d7aa45e8 (diff) | |
download | poky-c2d0ac3f0d8de681b28e0aca6dc41e93f4ca0540.tar.gz |
oeqa/ssh: Further improve process exit handling
It looks like there were further cases where orphaned processes may be left
behind since the .kill() calls may be unsuccessful if the process terminated
due to the terminate or through normal exit. In that situation .wait()
wouldn't have been called.
Further tweak the exit code paths to ensure .wait() is called to update the
returncode value before returning in all cases.
(From OE-Core rev: 0a0a1731e38edfa72a141e8fd8f2de52be562e94)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/core/target')
-rw-r--r-- | meta/lib/oeqa/core/target/ssh.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/meta/lib/oeqa/core/target/ssh.py b/meta/lib/oeqa/core/target/ssh.py index 72ed1adbf8..f22836d390 100644 --- a/meta/lib/oeqa/core/target/ssh.py +++ b/meta/lib/oeqa/core/target/ssh.py | |||
@@ -265,7 +265,6 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
265 | time.sleep(5) | 265 | time.sleep(5) |
266 | try: | 266 | try: |
267 | process.kill() | 267 | process.kill() |
268 | process.wait() | ||
269 | except OSError: | 268 | except OSError: |
270 | logger.debug('OSError when killing process') | 269 | logger.debug('OSError when killing process') |
271 | pass | 270 | pass |
@@ -274,6 +273,7 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
274 | " running time: %d seconds." % (timeout, endtime)) | 273 | " running time: %d seconds." % (timeout, endtime)) |
275 | logger.debug('Received data from SSH call:\n%s ' % lastline) | 274 | logger.debug('Received data from SSH call:\n%s ' % lastline) |
276 | output += lastline | 275 | output += lastline |
276 | process.wait() | ||
277 | 277 | ||
278 | else: | 278 | else: |
279 | output_raw = process.communicate()[0] | 279 | output_raw = process.communicate()[0] |
@@ -288,10 +288,10 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
288 | except TimeoutExpired: | 288 | except TimeoutExpired: |
289 | try: | 289 | try: |
290 | process.kill() | 290 | process.kill() |
291 | process.wait() | ||
292 | except OSError: | 291 | except OSError: |
293 | logger.debug('OSError') | 292 | logger.debug('OSError') |
294 | pass | 293 | pass |
294 | process.wait() | ||
295 | 295 | ||
296 | options = { | 296 | options = { |
297 | "stdout": subprocess.PIPE, | 297 | "stdout": subprocess.PIPE, |
@@ -318,6 +318,7 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
318 | # whilst running and ensure we don't leave a process behind. | 318 | # whilst running and ensure we don't leave a process behind. |
319 | if process.poll() is None: | 319 | if process.poll() is None: |
320 | process.kill() | 320 | process.kill() |
321 | if process.returncode == None: | ||
321 | process.wait() | 322 | process.wait() |
322 | logger.debug('Something went wrong, killing SSH process') | 323 | logger.debug('Something went wrong, killing SSH process') |
323 | raise | 324 | raise |