Documentation ¶
Overview ¶
Package pipe extends os.exec, making it easier to create pipes to subcommands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
Cmd is drop-in replacement for exec.Cmd, extended with the Pipe method.
func CommandContext ¶
CommandContext returns a new Cmd. See exec.CommandContext for details.
func (*Cmd) MakePipePair ¶ added in v0.22.0
MakePipePair makes a pair of pipes that can be used for bi-directional communication with the child process.
Cmd.ExtraFiles should not be modified directly if MakePipePair is called.
Wait will close ParentWriter automatically after seeing the command exit. A caller need only close ParentWriter to force the pipe to close sooner. For example, if the command being run will not exit until standard input is closed, the caller must close ParentWriter.
Wait will close ParentReader automatically after seeing the command exit, so most callers need not close ParentReader themselves. It is thus incorrect to call Wait before all reads from ParentReader have completed. For the same reason, it is incorrect to use Run when using MakePipePair. See the exec.Cmd.StdoutPipe example 1 for idiomatic usage.
type PipePair ¶ added in v0.22.0
type PipePair struct { ParentReader io.ReadCloser // Reader from which parent can read ParentWriter io.WriteCloser // Writer to which parent can write ChildReader uintptr // Descriptor from which child can read ChildWriter uintptr // Descriptor to which child can write }
PipePair holds a pair of pipes that can be used for bi-directional communication with a child process.