pexec

package
v0.4.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2023 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrArgsListEmpty = errors.New("args list empty")
  1. one
  2. two
  3. three
  4. Eliminate kk

Functions

func ExecStream

func ExecStream(stdin io.Reader, stdout io.WriteCloser, stderr io.WriteCloser,
	env []string, ctx context.Context, startCallback func(err error),
	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
  • 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL