exec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SigIntDelay  = 2 * time.Second
	SigKillDelay = 5 * time.Second
)

Variables

This section is empty.

Functions

func ArgToCmd

func ArgToCmd(ctx context.Context, args ...[]string) (cmds []*std_exec.Cmd)

func CmdToString

func CmdToString(cmds ...*std_exec.Cmd) string

CmdToString stringifies an os/exec.Cmd.

Types

type CommonExecutor

type CommonExecutor struct{}

CommonExecutor provides a general case Executor implementation.

func (CommonExecutor) Buffered

func (c CommonExecutor) Buffered(ctx context.Context, cmds ...*std_exec.Cmd) (stdout *bytes.Buffer, stderr *bytes.Buffer, res PipelineResult, err error)

Buffered returns standard output/error in addition to the exit code.

It implements an Executor behavior.

func (CommonExecutor) Command

func (c CommonExecutor) Command(name string, arg ...string) *std_exec.Cmd

Command completely delegates to the os/exec method.

It implements an Executor behavior.

func (CommonExecutor) CommandContext

func (c CommonExecutor) CommandContext(ctx context.Context, name string, arg ...string) *std_exec.Cmd

CommandContext completely delegates to the os/exec method.

It implements an Executor behavior.

func (CommonExecutor) Pty

func (c CommonExecutor) Pty(cmd *std_exec.Cmd) error

Pty runs the command in a pseudo-terminal and returns an error only if the command fails to start.

It implements an Executor behavior.

Author: https://github.com/kr/pty/blob/fa756f09eeb418bf1cc6268c66ceaad9bb98f598/README.md

func (CommonExecutor) Standard

func (c CommonExecutor) Standard(ctx context.Context, stdout io.Writer, stderr io.Writer, stdin io.Reader, cmds ...*std_exec.Cmd) (res PipelineResult, err error)

Standard allows standard in, out, and error to be customized.

It implements an Executor behavior.

type PipelineResult

type PipelineResult struct {
	// Cmd stores more detail about each process executed in the pipeline.
	Cmd map[*std_exec.Cmd]Result
}

type Result

type Result struct {
	Code int

	// Pid supports concerns like verifying the process exited.
	Pid int

	// Pgid supports concerns like verifying the process group exited.
	//
	// Values are NOT pre-negated, e.g. for syscall.Kill.
	Pgid int

	Stdout *bytes.Buffer
	Stderr *bytes.Buffer

	Err error
}

Jump to

Keyboard shortcuts

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