Skip to content

Refuse watch mode when stdout is not a terminal - #984

Open
Saadanjum0 wants to merge 1 commit into
dalance:masterfrom
Saadanjum0:fix/watch-requires-tty
Open

Saadanjum0 wants to merge 1 commit into
dalance:masterfrom
Saadanjum0:fix/watch-requires-tty

Conversation

@Saadanjum0

Copy link
Copy Markdown

Problem

procs -w | cat (or > file) enters the interactive watch TUI and writes ANSI frames into the pipe forever (see #982).

Cause

run_watch never checks that stdout is a terminal.

Fix

Bail with --watch requires a terminal, but stdout is not a TTY before starting the watcher. Non-watch piping (procs | cat) is unaffected.

Testing

  • Added test_watch_requires_tty; cargo test passes (19 tests).
  • Manually: procs -w | head and procs -w </dev/null | cat now print the error and exit.

Previously 'procs -w | cat' streamed ANSI screen frames into the pipe forever. Now it exits with an error, like top and watch do. Plain output piping is unchanged. Refs dalance#982.
@Saadanjum0
Saadanjum0 force-pushed the fix/watch-requires-tty branch from 818ad5a to 6c1da28 Compare October 9, 2026 07:00
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.

1 participant