process

package
v3.0.0-...-c194909 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cat

func Cat(path string) (string, error)

Replicates how the command line tool `cat` works, but is more verbose about what it does

func FormatCommand

func FormatCommand(command string, args []string) string

FormatCommand formats a command amd arguments for human reading

func GetPgid

func GetPgid(pid int) (int, error)

func Run

func Run(l logger.Logger, command string, arg ...string) (string, error)

func SignalString

func SignalString(s syscall.Signal) string

SignalString returns the name of the given signal. e.g. SignalString(syscall.Signal(15)) // "SIGTERM"

func StartPTY

func StartPTY(c *exec.Cmd) (*os.File, error)

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

func (*Buffer) String

func (l *Buffer) String() string

func (*Buffer) Write

func (l *Buffer) Write(b []byte) (int, error)

type Config

type Config struct {
	PTY             bool
	Timestamp       bool
	Path            string
	Args            []string
	Env             []string
	Stdout          io.Writer
	Stderr          io.Writer
	Dir             string
	Context         context.Context
	InterruptSignal Signal
}

Configuration for a Process

type Prefixer

type Prefixer struct {
	// contains filtered or unexported fields
}

func NewPrefixer

func NewPrefixer(w io.Writer, f func() string) *Prefixer

func (*Prefixer) Write

func (p *Prefixer) Write(data []byte) (n int, err error)

type Process

type Process struct {
	// contains filtered or unexported fields
}

Process is an operating system level process

func New

func New(l logger.Logger, c Config) *Process

New returns a new instance of Process

func (*Process) Done

func (p *Process) Done() <-chan struct{}

Done returns a channel that is closed when the process finishes

func (*Process) Interrupt

func (p *Process) Interrupt() error

Interrupt the process on platforms that support it, terminate otherwise

func (*Process) Pid

func (p *Process) Pid() int

Pid is the pid of the running process

func (*Process) Run

func (p *Process) Run() error

Run the command and block until it finishes

func (*Process) Started

func (p *Process) Started() <-chan struct{}

Started returns a channel that is closed when the process is started

func (*Process) Terminate

func (p *Process) Terminate() error

Terminate the process

func (*Process) WaitResult

func (p *Process) WaitResult() error

WaitResult returns the raw error returned by Wait()

func (*Process) WaitStatus

func (p *Process) WaitStatus() syscall.WaitStatus

WaitStatus returns the status of the Wait() call

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner(l logger.Logger) *Scanner

func (*Scanner) ScanLines

func (s *Scanner) ScanLines(r io.Reader, f func(line string)) error

type Signal

type Signal int
const (
	SIGHUP  Signal = 1
	SIGINT  Signal = 2
	SIGQUIT Signal = 3
	SIGUSR1 Signal = 10
	SIGUSR2 Signal = 12
	SIGTERM Signal = 15
)

func ParseSignal

func ParseSignal(sig string) (Signal, error)

func (Signal) String

func (s Signal) String() string

Jump to

Keyboard shortcuts

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