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) RPipe ¶
func (c *Cmd) RPipe() (uintptr, io.ReadCloser, error)
RPipe returns the reading side of a pipe that will be connected to the subprocess when the command starts.
The subprocess can write to the pipe using the file descriptor returned by RPipe. Cmd.ExtraFiles should not be modified directly if RPipe is called.
Wait will close the pipe after seeing the command exit, so most callers need not close the pipe themselves. It is thus incorrect to call Wait before all reads from the pipe have completed. For the same reason, it is incorrect to use Run when using Pipe. See the exec.Cmd.StdoutPipe example 1 for idiomatic usage.
func (*Cmd) WPipe ¶
func (c *Cmd) WPipe() (uintptr, io.WriteCloser, error)
WPipe returns the writer side of a pipe that will be connected to the subprocess when the command starts.
The subprocess can read from the pipe using the file descriptor returned by WPipe. Cmd.ExtraFiles should not be modified directly if WPipe is called.
The pipe will be closed automatically after Wait sees the command exit. A caller need only call Close 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 the pipe.