Skip to content

std::os::pipe doesn't handle error correctly #14724

Closed
@hannobraun

Description

@hannobraun

The function std::os::pipe just fails if the call to libc::pipe returns an error code.

This can be easily triggered with the following program:

use std::io::Command;

fn main() {
    let mut p = Vec::new();

    loop {
        match Command::new("cat").spawn() {
            Ok(process) =>
                p.push(process),
            Err(error) =>
                fail!("Error: {}", error)
        }

        print!("{}\n", p.len());
    }
}

On my machine (Ubuntu 14.04, x86_64), the program fails at 338 processes with the following message:

task '<main>' failed at 'assertion failed: `(left == right) && (right == left)` (left: `-1`, right: `0`)', /home/hanno/Projects/vndf/vendor/rust/src/libstd/os.rs:517

I believe that os::pipe() should return a Result (IoResult?) which should be passed up the chain. When I tried implementing this change, however, I quickly ran into trouble with users of the function. While some already return IoResult and can just pass the error up the chain, others don't. I wasn't sure, if I should change even more function signatures or just fail in these cases.

Since this isn't a problem for me currently and my time is very limited, I won't work further on this, sorry!
Maybe someone who understands the requirements of the calling code better might want to take a look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions