Documentation
¶
Overview ¶
Package execx runs external processes with a hard timeout and reliable process-tree termination. A hung `go build`, `npm install`, or `git` can no longer wedge a Krate build: the deadline is enforced and the whole tree is killed (on Windows `npx`/`go` are shims that spawn children, so killing only the direct child would leak the real work and block on its pipes).
Index ¶
- func Command(ctx context.Context, name string, args ...string) *exec.Cmd
- func ConfigureTree(cmd *exec.Cmd)
- func DefaultTimeout() time.Duration
- func KillTree(cmd *exec.Cmd)
- func Output(ctx context.Context, timeout time.Duration, dir string, env []string, ...) ([]byte, error)
- func Run(ctx context.Context, timeout time.Duration, dir string, env []string, ...) (stdout, stderr []byte, err error)
- func Timeout(envVar string, def time.Duration) time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Command ¶
Command builds an *exec.Cmd wired for tree termination: it is configured to start a new process group (Unix), and Cancel kills the whole tree.
func ConfigureTree ¶
ConfigureTree prepares a manually-built *exec.Cmd (e.g. a long-lived sidecar started with Start rather than Command) so KillTree can terminate its whole process group on Unix.
func DefaultTimeout ¶
DefaultTimeout returns the process-wide default timeout from the KRATE_EXEC_TIMEOUT environment variable (a Go duration, e.g. "90s"), or 0 when unset/invalid (0 means "no default" - callers may still pass an explicit timeout).
func Output ¶
func Output(ctx context.Context, timeout time.Duration, dir string, env []string, name string, args ...string) ([]byte, error)
Output is Run for the common case of needing only stdout.
func Run ¶
func Run(ctx context.Context, timeout time.Duration, dir string, env []string, name string, args ...string) (stdout, stderr []byte, err error)
Run executes name/args, enforcing timeout (falling back to DefaultTimeout when timeout <= 0). dir is the working directory (empty = inherit); env entries are appended to the current environment. It returns stdout, stderr, and an error that is descriptive on timeout.
Types ¶
This section is empty.