Documentation ¶
Overview ¶
Package process provides a helper for running and managing a subprocess.
It is intended for internal use by buildkite-agent only.
Index ¶
- Variables
- func Cat(path string) (string, error)
- func FormatCommand(command string, args []string) string
- func GetPgid(pid int) (int, error)
- func Run(l logger.Logger, command string, arg ...string) (string, error)
- func SignalString(s syscall.Signal) string
- func StartPTY(c *exec.Cmd) (*os.File, error)
- type Buffer
- type Config
- type Process
- func (p *Process) Done() <-chan struct{}
- func (p *Process) Interrupt() error
- func (p *Process) Pid() int
- func (p *Process) Run(ctx context.Context) error
- func (p *Process) Started() <-chan struct{}
- func (p *Process) Terminate() error
- func (p *Process) WaitResult() error
- func (p *Process) WaitStatus() WaitStatus
- type Scanner
- type Signal
- type Timestamper
- type WaitStatus
Constants ¶
This section is empty.
Variables ¶
var ErrNotWaitStatus = errors.New(
"unimplemented for systems where exec.ExitError.Sys() is not syscall.WaitStatus",
)
Functions ¶
func FormatCommand ¶
FormatCommand formats a command amd arguments for human reading
func SignalString ¶ added in v3.21.0
SignalString returns the name of the given signal. For example, SignalString(syscall.Signal(15)) // "SIGTERM"
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer implements a concurrent-safe output buffer for processes.
func (*Buffer) Close ¶ added in v3.51.0
Close closes the buffer. Further writes will return io.ErrClosedPipe.
func (*Buffer) ReadAndTruncate ¶ added in v3.45.0
ReadAndTruncate reads the unread contents of the buffer, and then truncates (empties) the buffer.
type Config ¶
type Config struct { PTY bool Timestamp bool Path string Args []string Env []string Stdin io.Reader Stdout io.Writer Stderr io.Writer Dir string InterruptSignal Signal SignalGracePeriod time.Duration }
Configuration for a Process
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process is an operating system level process
func (*Process) Done ¶
func (p *Process) Done() <-chan struct{}
Done returns a channel that is closed when the process finishes
func (*Process) Started ¶
func (p *Process) Started() <-chan struct{}
Started returns a channel that is closed when the process is started
func (*Process) WaitResult ¶
WaitResult returns the raw error returned by Wait()
func (*Process) WaitStatus ¶
func (p *Process) WaitStatus() WaitStatus
WaitStatus returns the status of the Wait() call
type Timestamper ¶ added in v3.60.0
type Timestamper struct {
// contains filtered or unexported fields
}
Timestamper inserts timestamps generated by a callback at the start of each line, and inside lines when the line is...printed...very...slowly.
func NewTimestamper ¶ added in v3.60.0
NewTimestamper sets up a Timestamper outputting to an io.Writer w. Timestamps are formatted with f, and non-prefix timestamps are inserted on writes that occur after timeout (duration since the previous timestamp).
func (*Timestamper) Write ¶ added in v3.60.0
func (p *Timestamper) Write(data []byte) (n int, err error)
Write writes the given data, plus any additional timestamps necessary, to the Timestamper's output. Timestamps are written at the start of each line, and possibly again within lines that are written incrementally over a long period of time.