process

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExecTimeout represent a timeout error
	ErrExecTimeout = errors.New("Process execution timeout")

	// DefaultTimeout is the timeout used by Exec* family
	// of function when timeout parameter is omitted or
	// passed as -1
	// NOTE: could be custom in config file for default.
	DefaultTimeout = 60 * time.Second
)
View Source
var (
	Processes []*Process
)

List of existing processes.

Functions

func Add

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

Add adds a existing process and returns its PID.

func Exec

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

Exec runs a command and waits for its completion up to DefaultTimeout. Returns its complete stdout and stderr outputs and an error, if any (including timeout)

func ExecDir

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

ExecDir works exactly like ExecDirEnv except no environment variable is provided.

func ExecDirEnv added in v1.0.0

func ExecDirEnv(timeout time.Duration, dir, desc string, env []string, cmdName string, args ...string) (string, string, error)

ExecDirEnv runs a command in given path and environment variables, and waits for its completion up to the given timeout (or DefaultTimeout if -1 is given). Returns its complete stdout and stderr outputs and an error, if any (including timeout)

func ExecTimeout

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

ExecTimeout runs a command and waits for its completion up to the given timeout (or DefaultTimeout if -1 is given). Returns its complete stdout and stderr outputs and an error, if any (including timeout)

func Kill

func Kill(pid int64) error

Kill kills and removes a process from list.

func Remove

func Remove(pid int64)

Remove removes a process from list.

Types

type Process

type Process struct {
	Pid         int64 // Process ID, not system one.
	Description string
	Start       time.Time
	Cmd         *exec.Cmd
}

Process represents a working process inherit from Gogs.

Jump to

Keyboard shortcuts

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