Skip to content

Commit 1dbd699

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]>
1 parent a3c068f commit 1dbd699

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
@@ -214,7 +214,7 @@ def _run(self, cmd, codec="utf-8", decodeerrors="strict", timeout=None):
214214
stderr_pipe = subprocess.PIPE
215215
try:
216216
sub = subprocess.Popen(
217-
complete_cmd, stdout=subprocess.PIPE, stderr=stderr_pipe
217+
complete_cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=stderr_pipe
218218
)
219219
except:
220220
raise ExecutionError(

0 commit comments

Comments
 (0)