Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrArgsListEmpty = errors.New("args list empty")
Functions ¶
func ExecStream ¶
func ExecStream(stdin io.Reader, stdout io.WriteCloser, stderr io.WriteCloser, ctx context.Context, args ...string) (statusCode int, isCancel bool, err error)
ExecStream executes a system command using the exec.Cmd type and flexible streaming.
- ExecStream blocks during command execution
- ExecStream returns any errors occurring during launch or execution including errors in copy threads
- any stream provided is not closed. However, upon return from ExecStream all i/o operations have completed and streams may be closed as the case may be
- successful exit is: statusCode == 0, isCancel == false, err == nil
- context cancel exit is: statusCode == -1, isCancel == true, err == nil
- — statusCode -1 means the process was terminated by signal such as ^C or SIGTERM
- failure is: statusCode != 0, isCancel == false, err != nil
- —
- args is the command followed by arguments.
- args[0] must specify an executable in the file system. env.PATH is used to resolve the command executable
- if stdin should not be used, pio.EofReader can be used
- for stdout and stderr pio has usable types:
- — pio.NewWriteCloserToString
- — pio.NewWriteCloserToChan
- — pio.NewWriteCloserToChanLine
- — pio.NewReadWriteCloserSlice
- if stdin stdout or stderr are nil, os.Stdin os.Stdout os.Stderr are used. Additional threads are used to copy data when stdin stdout or stderr are non-nil
- If env is nil, the new process uses the current process’ environment
- ctx is used to kill the process (by calling os.Process.Kill) if the context becomes done before the command completes on its own
- startCallback is invoked immediately after cmd.Exec.Start returns with its result. To not use a callback, set startCallback to nil
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.