Skip to content

BrokenPipe sometimes not reported #37807

Description

@jorendorff

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions