Documentation
¶
Overview ¶
Package subprocess runs one external command with the conventions every Dockhand tool runner shares: a bounded wait after cancellation, captured output, the context error joined into the cause, and one error shape that names the tool, its command, and what it wrote to stderr. Each caller keeps its own environment policy; this package never adds to or filters it.
A command run to completion, for its output or its exit, goes through Run. os/exec is used directly only by one that holds the terminal, as an editor or xcodes does; runs as long as its caller, as the Tcl interpreter, a guest, and a person's build do; streams what it reads and writes, as a decompressor does; or outlives the process, as the background cleanup does.
Index ¶
Constants ¶
const DefaultWaitDelay = 15 * time.Second
DefaultWaitDelay is how long a command's output may take to arrive once it has exited, and a command may outlive a canceled context before it's killed. The timer starts as the process exits, so it bounds copying what the process already wrote: a second's delay failed git ls-tree under a load average of 190, "exec: WaitDelay expired before I/O complete". A canceled command is killed at once, so the delay matters only to a command whose children keep its pipes open, which is a hang this ends.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
Error reports a failed command with what it wrote to standard error, or to the combined buffer when the streams were merged.
type Spec ¶
type Spec struct {
// Tool names the program in errors, such as "git" or "tart".
Tool string
// Command names the invocation in errors; empty selects the first argument.
Command string
Path string
Args []string
Dir string
// Env is the complete environment; nil inherits the process environment.
Env []string
Stdin io.Reader
// Stdout receives standard output in addition to the captured copy.
Stdout io.Writer
// StdoutOnly sends standard output to Stdout alone, uncaptured, for a
// stream too large to keep, such as a file being transferred; with
// Combined, standard error too. Where Stdout is a file, the program
// writes it itself, and goes on writing if this process ends.
StdoutOnly bool
// Stderr receives standard error in addition to the captured copy,
// as Stdout does standard output; Combined sends it to Stdout instead.
Stderr io.Writer
// Combined captures standard error into the same buffer as standard output.
Combined bool
ExtraFiles []*os.File
// WaitDelay bounds how long the process may outlive a canceled context,
// and how long its output may take to arrive once it has exited; zero
// selects DefaultWaitDelay.
WaitDelay time.Duration
// Group starts the program in a process group of its own, which a
// terminal's interrupt doesn't reach, and a canceled context asks it
// to stop with SIGTERM, its whole group where it may, before
// WaitDelay's kill: the local provider's guest program, whose builds
// are its children.
Group bool
// Limit bounds the captured bytes of each stream; zero imposes none.
Limit int64
// Drain, with a Limit, reads a stream on past it and drops the rest,
// rather than failing the command: it then ends as it would have, its
// exit status the verdict, as patch's is. A stream no longer read
// broke the command's pipe, and failed it, or killed it, for its
// output alone (the limits sweep, 2026-10-01).
Drain bool
}
Spec describes one invocation.