Closed
Description
Try piping this program's stdout to head
. After the first 10 lines, head
will exit. The pipe is now broken, so the next write should fail, and we should get thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)'
Instead, the Rust program keeps running indefinitely. GDB says SIGPIPE
is "received" (but I guess ignored) by the process every time it tries to write.
Feels like a race condition: if you remove the sleep
or just change it to be short, println!
panics as expected.
// usage: ./yep | head
use std::time::Duration;
use std::thread::sleep;
fn main() {
loop {
println!("y"); // should panic after `head` exits
sleep(Duration::new(0, 250_000_000));
}
}
tested on Linux, rustc 1.15.0-nightly (0ed951993 2016-11-14)