Skip to content

Can't shutdown stdin of process #2199

@daniel-emotech

Description

@daniel-emotech

Version

0.2.11

Platform

Ubuntu 18.04 x64

Subcrates

process, io

Description

So I'm piping into and out of a process using tokio process. And the input goes fine, and the output pipe was getting to the last byte then hanging (when I did it in chunks) or just hanging if I tried to use read_to_end.

I ended up diagnosing this further and finding that the stdin wasn't being closed so I added a shutdown() to my code but then the write hung there (write function included).

async fn write_buffer<W>(data: &[u8], mut w: W) -> io::Result<()> where W: ASyncWriteExt + Unpin {
    let mut buffer = Cursor::new(data);
    while buffer.has_remaining() {
        w.write_buf(&mut buffer).await?;
    }
    w.shutdown().await?; // It hangs here
}

To solve this temporarily I've removed the shutdown and in my read I read chunks into a buffer and have a timeout to spot the end of stream since the program I'm piping to/from is very fast. But I'm wondering if there's an issue there

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-bugCategory: This is a bug.M-processModule: tokio/process

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions