process

package
v0.11.86 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TIMEOUT = 60 * time.Second

Variables

View Source
var (
	ErrExecTimeout = errors.New("Process execution timeout")
)
View Source
var Processes []*Process

Functions

func Add

func Add(desc string, cmd *exec.Cmd) int64

Add adds a process to global list and returns its PID.

func Exec

func Exec(desc, cmdName string, args ...string) (string, string, error)

Exec starts executing a shell command, it tracks corresponding its process and use default timeout.

func ExecDir

func ExecDir(timeout time.Duration, dir, desc, cmdName string, args ...string) (string, string, error)

Exec starts executing a shell command in given path, it tracks corresponding process and timeout.

func ExecTimeout

func ExecTimeout(timeout time.Duration, desc, cmdName string, args ...string) (string, string, error)

Exec starts executing a shell command, it tracks corresponding process and timeout.

func Kill

func Kill(pid int64) error

Kill kills and removes a process from global list.

func Remove

func Remove(pid int64) bool

Remove removes a process from global list. It returns true if the process is found and removed by given pid.

Types

type Process

type Process struct {
	PID         int64
	Description string
	Start       time.Time
	Cmd         *exec.Cmd
}

Process represents a running process calls shell command.

Jump to

Keyboard shortcuts

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