Skip to content

anykey: only watch stdin when it is an interactive terminal - #14

Closed
jakob-tsd wants to merge 1 commit into
sigrokproject:masterfrom
jakob-tsd:anykey
Closed

jakob-tsd wants to merge 1 commit into
sigrokproject:masterfrom
jakob-tsd:anykey

Conversation

@jakob-tsd

Copy link
Copy Markdown

This allows to run this:

sigrok-cli ..... < /dev/null

which removes the possiblity of accentially interrupting a capture.

add_anykey() installed the "press any key to stop" stdin watch
unconditionally. When stdin was redirected from a non-interactive source
(e.g. /dev/null) it was immediately readable / at EOF,
which GLib reports as G_IO_IN, so the watch fired right away and stopped
acquisition immediately.

Skip the key watch when stdin is not a terminal.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Tested on Linux and working by a human (me).
I cannot test on Windows, so keeping the old behavoir there.
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.

2 participants