Skip to content

Windows: std::process::Command may pass asynchronous pipes to child process #95759

Closed

Description

Rust assumes stdio handles are opened for synchronous access (as will most other Windows processes). However, when passing ChildStdOut, ChildStdIn or ChildStdErr to a new Command the pipes passed in are asynchronous. For a full test case see src/test/ui-fulldeps/stdio-from.rs but here's a shorter example:

fn try_it(a: &mut Child, b: &mut Child) -> io::Result<()> {
    let mut child = Command::new("application")
        .stdin(a.stdout.take().unwrap())
        .stdout(b.stdin.take().unwrap())
        .spawn()?;

    assert!(child.wait()?.success());
    Ok(())
}

This is related to an older issue: #38811 (comment)

This can cause soundness issues described in #81357.

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

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.O-windowsOperating system: WindowsT-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions