summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-07-29 09:00:49 +0100
committerSteve Sakoman <steve@sakoman.com>2023-08-26 04:24:02 -1000
commit464b034745e3baf56b65acaf94ccdb39e1611fc3 (patch)
tree730d544c34a484233218c4a2bc1101bf3152b973
parent1efc676afc2e3373e3bbf05a736b67056adc4ad4 (diff)
downloadpoky-464b034745e3baf56b65acaf94ccdb39e1611fc3.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: e1e038ab01a599fcdd4aa6211b6d15cd01a5e2e3) 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.py5
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 69fdc146f0..6ee40083bd 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