process

package
v13.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package process provides a mechanism for running processes under a different user account to the current process

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(commandLine []string, workingDirectory string, env []string) (*Command, error)

func (*Command) DirectOutput

func (c *Command) DirectOutput(writer io.Writer)

func (*Command) Execute

func (c *Command) Execute() (r *Result)

func (*Command) Kill

func (c *Command) Kill() ([]byte, error)

func (*Command) String

func (c *Command) String() string

type Result

type Result struct {
	SystemError error
	ExitError   *exec.ExitError
	Duration    time.Duration
	Aborted     bool
	KernelTime  time.Duration
	UserTime    time.Duration
}

func (*Result) CrashCause

func (r *Result) CrashCause() error

Unlike on Windows, if there is a system error, we don't crash the worker, since this can be caused by task that tries to execute a non-existing command or a file that isn't executable. On Windows all commands are wrapped in a command shell execution, where not being able to execute a shell should cause the worker to panic.

func (*Result) Crashed

func (r *Result) Crashed() bool

Unlike on Windows, if there is a system error, we don't crash the worker, since this can be caused by task that tries to execute a non-existing command or a file that isn't executable. On Windows all commands are wrapped in a command shell execution, where not being able to execute a shell should cause the worker to panic.

See https://bugzil.la/1479415

func (*Result) ExitCode

func (r *Result) ExitCode() int

Returns the exit code, or

-1 if the process has not exited
-2 if the process crashed
-3 it could not be established what happened
-4 if process was aborted

func (*Result) Failed

func (r *Result) Failed() bool

Unlike on Windows, a system error is grounds for a task failure, rather than a task exception, since it can be caused by e.g. a task trying to execute a command that doesn't exist, or trying to execute a file that isn't executable. Therefore a system error, or an exit error (process ran but returned non-zero exit code) or a task abortion are all task failures.

See https://bugzil.la/1479415

func (*Result) FailureCause

func (r *Result) FailureCause() error

func (*Result) String

func (r *Result) String() string

func (*Result) Succeeded

func (r *Result) Succeeded() bool

func (*Result) Verdict

func (r *Result) Verdict() string

Jump to

Keyboard shortcuts

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