Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
Cmd represents an external command being prepared or run.
It's an extension of exec.Cmd that kills the whole process tree instead of just the parent process
func Command ¶
Command returns the Cmd struct to execute the named program with the given arguments.
The provided context is used to kill the process tree (by calling syscall.Kill(-c.Process.Pid, syscall.SIGKILL)) if the context becomes done before the command completes on its own.
func (*Cmd) Run ¶
Run starts the specified command and waits for it to complete.
The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status.
If the command fails to run or doesn't complete successfully, the error is of type *ExitError. Other error types may be returned for I/O problems.
func (*Cmd) Start ¶
Start starts the specified command but does not wait for it to complete.
The Wait method will return the exit code and release associated resources once the command exits.
func (*Cmd) Wait ¶
Wait waits for the command to exit. It must have been started by Start.
The returned error is nil if the command runs, has no problems copying stdin, stdout, and stderr, and exits with a zero exit status.
If the command fails to run or doesn't complete successfully, the error is of type *ExitError. Other error types may be returned for I/O problems.
If c.Stdin is not an *os.File, Wait also waits for the I/O loop copying from c.Stdin into the process's standard input to complete.
Wait releases any resources associated with the Cmd.