Skip to content

Commit

Permalink
Wait for SSH command to complete after execution
Browse files Browse the repository at this point in the history
This patch resolves a problem that started to show up when fast 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 implementations.

The right thing to do is to wait for the process completion, once we
finish to read stdout. In this way, return_value will be != None and we
can process fast commands execution.
  • Loading branch information
acerv committed Mar 13, 2024
1 parent 6cc0495 commit 5a21659
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions libkirk/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5a21659

Please sign in to comment.