Documentation
¶
Overview ¶
Package proctree runs a shell command as the root of its own process tree, streams its output, and kills the whole tree on cancellation, timeout or a failed output callback. It is the one shell executor behind the bash tool and the harness Exec port.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Kill ¶
Kill kills the process group led by pid, which Isolate started; a group already gone is os.ErrProcessDone. It never signals pid alone: after the leader is reaped that pid may be reused.
func Run ¶
Run runs command to completion and returns the shell's exit status, 128 plus the signal number when a signal ended it.
func SpawnErrorCode ¶
SpawnErrorCode is the code Node reports for a failed spawn ("ENOENT"), or "".
Types ¶
type Command ¶
type Command struct {
Script string
Dir string
Env []string
// Timeout is in seconds; nil means none.
Timeout *float64
// Shell resolves the shell once the timeout and context are checked.
Shell func() (Shell, error)
// Started receives the pid of the shell, which leads the tree.
Started func(pid int)
// OnData receives each output chunk, one call at a time; an error kills
// the tree and becomes the run's error.
OnData func(stderr bool, chunk []byte) error
}
Command is one run of a shell script.