Handle a closed CLI stdout pipe without a printing panic
Problem
wavec --help panics when its output pipe has no readers, rather than following a defined CLI I/O error policy.
Reproduction and evidence
Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.
Executed a deterministic pipe fixture equivalent to:
import os, subprocess
r, w = os.pipe()
os.close(r)
p = subprocess.Popen(["target/debug/wavec", "--help"], stdout=w, stderr=subprocess.PIPE)
os.close(w)
_, error = p.communicate(timeout=5)
print(p.returncode, error.decode())
Observed: exit 101 and failed printing to stdout: Broken pipe. This is Wave not handling a normal Rust I/O error, not a Rust vulnerability.
Scope
Define consistent BrokenPipe handling at CLI output boundaries while preserving ordinary output and useful handling of other I/O errors.
Starting points: src/cli.rs:4566, tools/src/cli.rs:166.
Completion criteria
- [ ] Closed-reader help/print paths do not produce a panic backtrace.
- [ ] Normal output remains unchanged.
- [ ] Use an OS-pipe regression instead of timing-sensitive piping through head.
This is a bounded newcomer task with the starting point and focused negative/positive checks above.