Documentation
¶
Index ¶
- func KillProcessGroup(p *exec.Cmd) error
- func MergeArgs(sets ...[]string) []string
- func SetProcessGroup(p *exec.Cmd)
- func TerminateProcessGroup(p *exec.Cmd) error
- func UseProcessGroup(p *exec.Cmd)
- type Command
- type Option
- func WithCancel(fn func(*os.Process) error) Option
- func WithContext(ctx context.Context) Option
- func WithDir(dir string) Option
- func WithEnv(envs ...string) Option
- func WithInput(inputs ...io.Reader) Option
- func WithMaxBuffer(n int) Option
- func WithProcessGroup() Option
- func WithStderr(w io.Writer) Option
- func WithStdout(w io.Writer) Option
- func WithWaitDelay(d time.Duration) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KillProcessGroup ¶ added in v0.8.0
A group already gone is not an error.
func MergeArgs ¶ added in v0.4.13
MergeArgs merges left to right: a repeated flag keeps its first position and its last values (--f=v and --f v are the same flag). Arity is inferred, so repeatable flags collapse and a positional after a flag becomes its value; there is no "--" terminator.
func SetProcessGroup ¶ added in v0.8.0
func TerminateProcessGroup ¶ added in v0.8.0
A group already gone is not an error.
func UseProcessGroup ¶ added in v0.7.0
UseProcessGroup needs an exec.CommandContext command (exec ignores Cancel otherwise); cancel SIGTERMs the group.
Types ¶
type Command ¶
type Command interface {
Start() error
// Wait errors before Start and on a second call.
Wait() error
Run() error
// Terminate sends SIGTERM (to the group under WithProcessGroup), or kills where signals are
// unsupported; an ended command is not an error.
Terminate() error
Kill() error
// Output and Error capture only streams given no writer (bounded by WithMaxBuffer); custom
// writers are called from exec's goroutines, stdout and stderr concurrently.
Output() string
Error() string
// ExitCode is -1 until Wait returns.
ExitCode() int
String() string
}
Command runs once; call Wait once, from one goroutine, and read Output, Error and ExitCode only after it returns.
type Option ¶
type Option func(*cmd)
func WithContext ¶
func WithInput ¶
WithInput with no readers passes the parent's stdin; without WithInput stdin is the null device.
func WithMaxBuffer ¶ added in v0.3.13
func WithProcessGroup ¶ added in v0.7.0
func WithProcessGroup() Option