exec

package
v0.13.9 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrWaitPIDTimeout = fmt.Errorf("Timed out waiting for PID to complete")
	Unredacted        = Redact(nil)
)
View Source
var DefaultCmdOpts = CmdOpts{
	Timeout:         time.Duration(0),
	Redactor:        Unredacted,
	TimeoutBehavior: TimeoutBehavior{syscall.SIGKILL, false},
}

Functions

func Redact

func Redact(items []string) func(text string) string

func RunCommand

func RunCommand(name string, opts CmdOpts, arg ...string) (string, error)

func RunCommandExt

func RunCommandExt(cmd *exec.Cmd, opts CmdOpts) (string, error)

RunCommandExt is a convenience function to run/log a command and return/log stderr in an error upon failure.

func WaitPID

func WaitPID(pid int, opts ...WaitPIDOpts) error

WaitPID waits for a non-child process id to exit

Types

type CmdError

type CmdError struct {
	Args   string
	Stderr string
	Cause  error
}

func (*CmdError) Error

func (ce *CmdError) Error() string

func (*CmdError) String

func (ce *CmdError) String() string

type CmdOpts

type CmdOpts struct {
	// Timeout determines how long to wait for the command to exit
	Timeout time.Duration
	// Redactor redacts tokens from the output
	Redactor func(text string) string
	// TimeoutBehavior configures what to do in case of timeout
	TimeoutBehavior TimeoutBehavior
}

type TimeoutBehavior

type TimeoutBehavior struct {
	// Signal determines the signal to send to the process
	Signal syscall.Signal
	// ShouldWait determines whether to wait for the command to exit once timeout is reached
	ShouldWait bool
}

TimeoutBehavior defines behavior for when the command takes longer than the passed in timeout to exit By default, SIGKILL is sent to the process and it is not waited upon

type WaitPIDOpts

type WaitPIDOpts struct {
	PollInterval time.Duration
	Timeout      time.Duration
}

WaitPIDOpts are options to WaitPID

Jump to

Keyboard shortcuts

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