Skip to content

lsd: Print plain table when not on a terminal - #206

Open
Cassian433 wants to merge 1 commit into
frida:mainfrom
Cassian433:lsd-non-interactive
Open

Cassian433 wants to merge 1 commit into
frida:mainfrom
Cassian433:lsd-non-interactive

Conversation

@Cassian433

Copy link
Copy Markdown

Fixes #200.

frida-ls-devices always starts the prompt_toolkit Application. With stdin from /dev/null, as in CI, run() raises EOFError and the reactor thread then fails in _on_stop():

Warning: Input is not a terminal (fd=0).
...
EOFError
...
Exception: Application is not running. Application.exit() failed.

Exit status 1 and no table. With only stdout piped it exits 0, but every spinner frame and redraw ends up in the output.

When _have_terminal is false or TERM=none (same check as ps.py), lsd now skips the Application, queries the devices in parallel and prints the same Id/Type/Name/OS table. The OS string formatting moved into _query_os() so both paths share it. Ctrl+C cancels the pending queries like a key press does in the UI.

frida-ls-devices < /dev/null now prints the table and exits 0, | cat -A shows the table with no ^M or escape codes, and the UI on a pty is unchanged. tests/test_lsd.py runs main() against fake devices with a non-TTY stdin; it fails on main with the EOFError above and passes here. Tested on Ubuntu 24.04, Python 3.12, frida 17.23.3, prompt_toolkit 3.0.53.

#160 looks like a separate startup race on a real terminal and isn't touched here.

With stdin redirected, Application.run() fails with EOFError, and with
stdout piped we emit every spinner frame. Print a plain table instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(frida-ls-devices): avoid crashing when stdin is not a TTY

1 participant