sub

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PumpLines

func PumpLines(inlet PumpSource, sink chan<- string, onDone *sync.WaitGroup, readyGate *sync.WaitGroup)

func PumpPrefixedChannel

func PumpPrefixedChannel(prefix string, source <-chan string, onDone *sync.WaitGroup)

Types

type GivePumpSource

type GivePumpSource struct {
	Source io.ReadCloser
}

func (*GivePumpSource) ObtainSource

func (g *GivePumpSource) ObtainSource() (io.ReadCloser, error)

type Option

type Option interface {
	Customize(cmd *exec.Cmd)
}

type ProcGroup

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

ProcGroup is an option to launch a command in a process group. Provides the capability to send signals to the entire process group, as well as convince wrappers around the group.

func WithProcGroup

func WithProcGroup() *ProcGroup

func (*ProcGroup) Customize

func (p *ProcGroup) Customize(cmd *exec.Cmd)

func (*ProcGroup) Kill

func (p *ProcGroup) Kill() error

Kill sends the SIGKILL to the group

func (*ProcGroup) Signal

func (p *ProcGroup) Signal(signal syscall.Signal) error

Signal dispatches the given signal to the process group. If the process is not running or this has not been attached then no signals are attached.

func (*ProcGroup) Terminate

func (p *ProcGroup) Terminate() error

Terminate sends SIGTERM to the group

type PumpSource

type PumpSource interface {
	ObtainSource() (io.ReadCloser, error)
}

func FromCmdStderr

func FromCmdStderr(cmd *exec.Cmd) PumpSource

func FromCmdStdout

func FromCmdStdout(cmd *exec.Cmd) PumpSource

type Subcommand

type Subcommand struct {
	Options []Option
	// contains filtered or unexported fields
}

func NewSubcommand

func NewSubcommand(programName string, args []string) *Subcommand

func (*Subcommand) Interact

func (s *Subcommand) Interact(stdin <-chan string, stdout chan<- string, stderr chan<- string) error

func (*Subcommand) Kill

func (s *Subcommand) Kill() error

Kill attempts to terminate the subcommand by sending an operating system kill signal.

NOTE: In the case of process cleanup this risks orphaning processes. Use `WithProcGroup` option and `Kill` with that instead.

func (*Subcommand) PumpToStandard

func (s *Subcommand) PumpToStandard(title string) error

PumpToStandard will run the given command

func (*Subcommand) Run

func (s *Subcommand) Run(stdout chan<- string, stderr chan<- string) error

func (*Subcommand) SendSignal

func (s *Subcommand) SendSignal(signal os.Signal) error

func (*Subcommand) WithOption

func (s *Subcommand) WithOption(opt Option)

type WorkingDir

type WorkingDir struct {
	Where string
}

func (*WorkingDir) Customize

func (w *WorkingDir) Customize(cmd *exec.Cmd)

Jump to

Keyboard shortcuts

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