Skip to main content

Module stdin_helper

Module stdin_helper 

Source
Expand description

Stdin reader with configurable timeout to prevent indefinite blocking. Stdin reader with timeout to prevent indefinite blocking when the upstream pipe is held open without sending data.

Used by remember body-from-stdin and edit body input to enforce a deadline (crate::constants::DEFAULT_STDIN_READ_TIMEOUT_SECS, override via XDG cli.stdin_timeout_secs). When the timeout fires, the spawned reader thread is leaked because std::io::stdin() cannot be cancelled from outside; this is acceptable in error scenarios because the process is about to exit anyway.

Two refusals happen before any read is attempted:

  • --no-input (or XDG cli.no_input) makes the refusal DECLARATIVE — it holds even when a pipe is attached and would have supplied data;
  • an interactive TTY makes it EMERGENT — there is no producer, so waiting for EOF would just burn the whole deadline.

Functions§

install_no_input
Installs the resolved --no-input decision for the whole process.
no_input
Whether stdin reads are refused for this invocation.
read_stdin
Reads stdin to a String with the configured deadline.
read_stdin_with_timeout
Reads stdin to a String with a hard deadline.