Skip to content

Commit 8e831f9

Browse files
driver/sshdriver: redirect /dev/null to stdin on run()
By default, no redirection will occur. That means a command run on the target consumes the stdin of our process. That is especially unfortunate if we expect interactive input, such as for the ManualPowerDriver, ManualSwitchDriver or in a REPL: shell.run_check("sleep 100 &") pidfile = "/tmp/pidfile" shell.run_check(f"pgrep sleep > {pidfile}") try: ssh.run(f"pwait --pidfile {pidfile}", timeout=1) except: from IPython import embed embed() This example shows that not all input reaches the IPython REPL. Fix this by redirecting /dev/null to stdin, so the command run via SSH do not receive unexpected input and do not compete over it. Signed-off-by: Bastian Krause <[email protected]> (cherry picked from commit 1dbd699)
1 parent 76a0495 commit 8e831f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

labgrid/driver/sshdriver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def _run(self, cmd, codec="utf-8", decodeerrors="strict", timeout=None):
204204
stderr_pipe = subprocess.PIPE
205205
try:
206206
sub = subprocess.Popen(
207-
complete_cmd, stdout=subprocess.PIPE, stderr=stderr_pipe
207+
complete_cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=stderr_pipe
208208
)
209209
except:
210210
raise ExecutionError(

0 commit comments

Comments
 (0)