Skip to content

std::process::Command hangs if piped stdout buffer fills #45572

Open
@Fraser999

Description

@Fraser999

There's an issue on Windows when using Stdio::piped() for stdout. If the child process writes too many bytes to stdout, it appears to get permanently blocked. A minimal test case (echo 2049 blank lines to cmd) is:

fn main() {
    ::std::process::Command::new("cmd")
        .args(&["/c", "for /l %i in (1, 1, 2049) do @echo["])
        .stdout(::std::process::Stdio::piped())
        .status();
}

This hangs for me, but succeeds if only 2048 echos are specified (which is why I'm suspecting it's related to filling the 4096-byte buffer).

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

    A-processArea: `std::process` and `std::env`C-bugCategory: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.T-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