Skip to content

os/exec: fix StdinPipe and maybe StdoutPipe #6270

@robpike

Description

@robpike
See also issue #4290.

StdinPipe (for instance) returns a WriteCloser but then closes it in Wait. That's bad
design: a package that returns a Closer shouldn't then close it for you silently.

But the real problem is that this property makes it impossible to use StdinPipe
correctly to deliver data to the process, since any program attempting to write to the
pipe to deliver input to the process must close the file descriptor itself to signal
EOF. There is a deadly embrace: The process won't exit until EOF; the EOF won't be
delivered until the process exits.

I believe StdinPipe should be deprecated, and a new method (call it XXX) that returns a
WriteCloser, but that Wait does not close that file descriptor. It would be the
well-documented responsibility of the client to close XXX explicitly.

I haven't thought through StdoutPipe but perhaps it has a related issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions