$ cat yes.rs
fn main() { loop { println!("y"); } }
$ rustc yes.rs && ./yes | head -n1
y
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', src/libstd/io/stdio.rs:692:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.
$ yes | head -n1
y
This was originally filed here but @sfackler determined the cause:
This is due to println! panicking on errors:
|
fn print_to<T>(args: fmt::Arguments, |
.
C-based programs typically just get killed off with a SIGPIPE, but Rust ignores that signal.
Note that to see the backtrace, the data being piped has to be large enough to overflow the kernel pipe buffer.
This was originally filed here but @sfackler determined the cause:
Note that to see the backtrace, the data being piped has to be large enough to overflow the kernel pipe buffer.