From 61562aba683e0fbc85cb9752f3bcbfc7e1f77173 Mon Sep 17 00:00:00 2001 From: Andrea Cervesato Date: Wed, 13 Mar 2024 16:17:46 +0100 Subject: [PATCH] Wait for SSH command to complete after execution This patch resolves a problem that started to show up when commands, such as 'cat' were executed on target. The original code was killing the command once we faced a return_value == None. This is obviously wrong and it probably comes from multiple SSH module iterations. The right thing to do is to wait for the completion of the process, once we terminate reading its stdout. In this way, return_value will be != None and we can process fast commands execution. --- libkirk/ssh.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libkirk/ssh.py b/libkirk/ssh.py index 3c09219..28bd2d3 100644 --- a/libkirk/ssh.py +++ b/libkirk/ssh.py @@ -269,8 +269,7 @@ async def run_command( if proc: self._procs.remove(proc) - if proc.returncode is None: - proc.kill() + await proc.wait() ret = { "command": command,