process

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2015 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package process contains an implementation of a callback-based asynchronous process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartAsync added in v0.0.9

func StartAsync(cmd *exec.Cmd, c *Callbacks) error

StartAsync runs the specified command in the background and calls the provided handlers during the proccess' lifetime. If there is an error starting the process, it is returned and none of the callbacks are called.

Types

type Callbacks added in v0.0.9

type Callbacks struct {
	// OnStart is called once the process has been started.
	OnStart func(p *os.Process)
	// OnExit will be called, if non-nil, once the process exits (with or without
	// an error).  OnExit is called after any call to either OnSuccess or OnError.
	OnExit func(state *os.ProcessState, err error)

	// OnSuccess will be called if it is non-nil and the process exits
	// successfully.
	OnSuccess func(state *os.ProcessState)
	// OnError will be called if it is non-nil and the process exits with an
	// error.
	OnError func(state *os.ProcessState, err error)
}

Callbacks is a set of callbacks to be called throughout a process' lifetime. Each callback can be nil to ignore that particular process state.

Jump to

Keyboard shortcuts

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