diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-07-29 09:00:49 +0100 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-08-18 03:57:05 -1000 |
commit | 7e020d4aea4d0378a6bb1dabf0cd3a46066b2a4b (patch) | |
tree | 259a83f9f3820f6244fb12ea2f6e01808c594b6f | |
parent | 51904d6c60617d42c9981a7857c6363ac7022e73 (diff) | |
download | poky-7e020d4aea4d0378a6bb1dabf0cd3a46066b2a4b.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: f647d1400bfa5b8eab81b2b2e2c86df306970a71)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 0a0a1731e38edfa72a141e8fd8f2de52be562e94)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-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 1cd496c2f4..a9566d9bd6 100644 --- a/meta/lib/oeqa/core/target/ssh.py +++ b/meta/lib/oeqa/core/target/ssh.py | |||
@@ -262,7 +262,6 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
262 | time.sleep(5) | 262 | time.sleep(5) |
263 | try: | 263 | try: |
264 | process.kill() | 264 | process.kill() |
265 | process.wait() | ||
266 | except OSError: | 265 | except OSError: |
267 | logger.debug('OSError when killing process') | 266 | logger.debug('OSError when killing process') |
268 | pass | 267 | pass |
@@ -271,6 +270,7 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
271 | " running time: %d seconds." % (timeout, endtime)) | 270 | " running time: %d seconds." % (timeout, endtime)) |
272 | logger.debug('Received data from SSH call:\n%s ' % lastline) | 271 | logger.debug('Received data from SSH call:\n%s ' % lastline) |
273 | output += lastline | 272 | output += lastline |
273 | process.wait() | ||
274 | 274 | ||
275 | else: | 275 | else: |
276 | output_raw = process.communicate()[0] | 276 | output_raw = process.communicate()[0] |
@@ -285,10 +285,10 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
285 | except TimeoutExpired: | 285 | except TimeoutExpired: |
286 | try: | 286 | try: |
287 | process.kill() | 287 | process.kill() |
288 | process.wait() | ||
289 | except OSError: | 288 | except OSError: |
290 | logger.debug('OSError') | 289 | logger.debug('OSError') |
291 | pass | 290 | pass |
291 | process.wait() | ||
292 | 292 | ||
293 | options = { | 293 | options = { |
294 | "stdout": subprocess.PIPE, | 294 | "stdout": subprocess.PIPE, |
@@ -315,6 +315,7 @@ def SSHCall(command, logger, timeout=None, **opts): | |||
315 | # whilst running and ensure we don't leave a process behind. | 315 | # whilst running and ensure we don't leave a process behind. |
316 | if process.poll() is None: | 316 | if process.poll() is None: |
317 | process.kill() | 317 | process.kill() |
318 | if process.returncode == None: | ||
318 | process.wait() | 319 | process.wait() |
319 | logger.debug('Something went wrong, killing SSH process') | 320 | logger.debug('Something went wrong, killing SSH process') |
320 | raise | 321 | raise |