Skip to content

os/exec: support additional io.Reader and io.Writer streams #15460

@docbrown

Description

@docbrown

The os/exec package currently only supports mapping io.Reader and io.Writer objects to Stdin, Stdout, and Stderr. It would be nice if Cmd supported adding additional readers and writers for other file descriptors. For example, I would like to have FFmpeg split an Ogg stream from Stdin into two separate io.Writers (one assigned to Stdout and the other on FD 3). I can do this by creating my own pipe and spinning up a goroutine to do the io.Copy, but that functionality is already built into os/exec. It just needs to be exposed in the public API. Perhaps something like:

cmd := exec.Command(...)
f, _ := cmd.WriterDescriptor(w) // or cmd.ReaderDescriptor(r)
cmd.ExtraFiles = append(cmd.ExtraFiles, f)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions