1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

host: Fix PopenBackgroundCommand stdin

The Popen object created for background command currently has no stdin
pipe, preventing the user from writing to it (it will be None instead of
being a file-like object).

Fix that by passing stdin=subprocess.PIPE to Popen constructor.
This commit is contained in:
Douglas Raillard 2021-08-18 16:18:11 +01:00 committed by Marc Bonnici
parent 47280f63da
commit e231cb0849
2 changed files with 2 additions and 1 deletions

View File

@ -138,6 +138,7 @@ class LocalConnection(ConnectionBase):
command, command,
stdout=stdout, stdout=stdout,
stderr=stderr, stderr=stderr,
stdin=subprocess.PIPE,
shell=True, shell=True,
preexec_fn=preexec_fn, preexec_fn=preexec_fn,
) )

View File

@ -600,7 +600,7 @@ def adb_background_shell(conn, command,
adb_cmd = get_adb_command(device, 'shell', adb_server) adb_cmd = get_adb_command(device, 'shell', adb_server)
full_command = '{} {}'.format(adb_cmd, quote(command)) full_command = '{} {}'.format(adb_cmd, quote(command))
logger.debug(full_command) logger.debug(full_command)
p = subprocess.Popen(full_command, stdout=stdout, stderr=stderr, shell=True) p = subprocess.Popen(full_command, stdout=stdout, stderr=stderr, stdin=subprocess.PIPE, shell=True)
# Out of band PID lookup, to avoid conflicting needs with stdout redirection # Out of band PID lookup, to avoid conflicting needs with stdout redirection
find_pid = '{} ps -A -o pid,args | grep {}'.format(conn.busybox, quote(uuid_var)) find_pid = '{} ps -A -o pid,args | grep {}'.format(conn.busybox, quote(uuid_var))