pub enum BrokenPipe {
Ignore,
Fail,
}app only.Expand description
How App exits when the reader closes stdout or stderr before the
output is written, as head -1 does.
A closed pipe never turns a failure into success, and never hides a more
specific code. A command that failed, or a parse error, keeps its own exit
code under either policy. A script never reads a failed run as a passing
one because its reader went away. A check such as $? -eq 2 behaves the
same under both.
A CLI built on ctl-core ignores SIGPIPE, as every Rust program does by default. A closed pipe then reaches it as a failed write, not as a signal.
The set is closed, and the enum is not #[non_exhaustive]. A run that
failed keeps its code under either policy. So a policy decides only
whether a successful run whose reader left still exits 0.
Variants§
Ignore
Exit with the code the command would have exited with had every byte
been read, and write nothing to stderr. A command that succeeded
exits 0: the reader had what it wanted, and a script under
set -o pipefail keeps going.
Fail
Exit 1 when the command succeeded, for a CLI that treats a reader that stopped early as an error. A command that already failed keeps its own code.