Conversation
When stdout is piped or redirected (e.g. 'gping 127.0.0.1 | cat' or 'gping host > out.txt'), gping entered its render loop anyway and flooded the consumer with ANSI drawing frames forever, or died with a cryptic broken-pipe error (os error 232 on Windows) once the reader went away. The UI is the graph itself and there is no plain-text mode to fall back to, so bail early with a clear error like other full-screen TUI tools (top/htop/bottom). --help/--version still work piped since clap handles them during argument parsing. Fixes orf#601
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #601.
Bug
gping <host> | cat(or any piped/redirected stdout) enters the ratatui render loop anyway and floods the consumer with ANSI frames forever.main()never checks stdout;CrosstermBackendhappily renders into a pipe — on Windows,enable_raw_mode()only affects the input console, which is still a tty, so nothing stops it.Fix (+8/-0)
Bail early when stdout isn't a terminal — right after the no-hosts check, before DNS resolution and thread spawn:
Matches top/htop/bottom behavior — gping has no plain-text mode, so refusing is the correct semantics.
Verified (Windows 11 + Linux)
gping 127.0.0.1 > out.txtgping 127.0.0.1 | exit-earlyError: os error 232qexits cleanly--help/-Vpipedcargo fmt --check+clippy --workspaceclean;cargo test -p gping18/18 (one pre-existing IPv6 env failure inpingerunrelated to this diff).