Repository navigation
Conversation
Watch mode (-w/--watch/--watch-interval) is an interactive TUI like top. With piped or redirected stdout it wrote ANSI screen frames into the pipe/file forever, and with a non-terminal stdin the getch thread spun at ~100% CPU. Bail out with a clear error instead. Fixes dalance#982
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 #982.
Bug
procs -wwith non-terminal stdout enters the TUI watch loop and emits ANSI frames into the pipe/file forever. A related case:procs -w </dev/nullmakes thegetchkeyboard thread spin at ~100% CPU (stdin.readreturnsOk(0)instantly in a tight loop) andqcan't quit.Plain
procs | catis correct and unchanged — only watch mode is broken on non-tty.Fix (+14/-1,
src/main.rs)In
run_watch— before any frame write orWatcher::start:IsTerminalis std (≥1.70; crate MSRV 1.88) — no dependency churn. Covers-w,--watch, and-W/--watch-interval(all funnel here). Bails through the existingerror:stderr printer → exit 1.Verified
procs -w | cat/> fileerror: --watch requires a terminal…, rc=1procs -w </dev/null(tty out)error: … stdin is not a TTY, rc=1procs -w | headprocs | catprocs -wreal ttyqquitscargo test24/24;fmt/clippyclean;x86_64-pc-windows-gnubuild green.