exec

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package exec is the one place a harness operation turns argv into a process. It never interprets a shell: every element of Argv reaches the child as one literal argument, so a metacharacter is data and can start no sibling command.

Index

Constants

View Source
const (
	DefaultTimeout     = 2 * time.Minute
	MaximumTimeout     = 10 * time.Minute
	DefaultOutputLimit = 32 * 1024
	MaximumOutputLimit = 1024 * 1024

	TimeoutExitCode = 124
)

Variables

This section is empty.

Functions

func Command

func Command(ctx context.Context, request Request) (*osexec.Cmd, error)

Command builds the child process without a shell. It fails closed on empty argv, an embedded NUL, or a non-absolute working directory.

Types

type Request

type Request struct {
	// Dir is the absolute working directory the process runs in.
	Dir string
	// Argv is the executable and its literal arguments. No element is parsed.
	Argv []string
	// Timeout bounds wall-clock time; OutputLimit bounds captured bytes.
	Timeout     time.Duration
	OutputLimit int
}

Request is one bounded direct execution.

type Result

type Result struct {
	ExitCode        int
	TimedOut        bool
	Stdout, Stderr  string
	StdoutTruncated bool
	StderrTruncated bool
}

func Run

func Run(ctx context.Context, request Request) (Result, error)

Run executes bounded argv and returns bounded output. Output past the limit is dropped rather than buffered, so a chatty process cannot exhaust memory.

Jump to

Keyboard shortcuts

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