process

package
v0.7.49 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package process starts the subprocesses Aviary owns, such as CLI providers and the ngrok tunnel, and makes sure none of them outlives Aviary.

Index

Constants

View Source
const CleanupTimedOutNote = "process cleanup timed out: something the agent started kept its output open after it exited, and was killed"

CleanupTimedOutNote is what a run that finished, but whose process cleanup timed out, notes instead of failing.

Variables

This section is empty.

Functions

func CleanupTimedOut added in v0.7.25

func CleanupTimedOut(err error) bool

CleanupTimedOut reports whether err is Wait's report that the child exited successfully but its output pipes stayed open past cmd.WaitDelay. The child itself finished; only the processes it left behind did not.

func CombinedOutput

func CombinedOutput(cmd *exec.Cmd) ([]byte, error)

CombinedOutput runs a tracked child and returns its standard output and standard error interleaved, the tracked equivalent of exec.Cmd.CombinedOutput.

func Command

func Command(ctx context.Context, binary string, args ...string) *exec.Cmd

Command is exec.CommandContext for a CLI provider such as claude or codex, started through ShimArgv. When the provider cannot be started without losing an argument, Start reports why, so the caller fails loudly instead of the CLI running on truncated arguments.

func ExitAfterReaping

func ExitAfterReaping(code int)

ExitAfterReaping terminates every owned subprocess before exiting, because os.Exit runs no deferred cleanup.

func Kill

func Kill(cmd *exec.Cmd) error

Kill ends a tracked child and everything it spawned at once, paused or not. It only signals and never waits, so it is safe as an exec.Cmd Cancel function while another goroutine is in Wait. Killing just the child would leave its descendants holding its output pipes, and a paused descendant never lets go of them, so Wait would never return.

func Output

func Output(cmd *exec.Cmd) ([]byte, error)

Output runs a tracked child and returns what it wrote to standard output, the tracked equivalent of exec.Cmd.Output.

func Pause

func Pause(cmd *exec.Cmd) error

Pause suspends a tracked child and everything it spawned, so nothing in the tree runs until Resume or a kill. The shutdown checkpoint uses it to commit an agent's checkout without catching a half-written file.

func ReapAll

func ReapAll()

ReapAll terminates every owned subprocess. It is safe to call more than once, so shutdown paths can call it defensively.

func Resume

func Resume(cmd *exec.Cmd) error

Resume lets a tree suspended by Pause run again.

func Run

func Run(cmd *exec.Cmd) error

Run runs a tracked child to completion.

func ShimArgv

func ShimArgv(binary string, args []string) (string, []string, error)

ShimArgv returns the program and arguments to start a CLI provider with.

On Windows a .cmd or .bat file can only run through cmd.exe, and cmd.exe ends the command line at the first newline, so a multi-line argument handed to an npm shim such as claude.cmd reached the CLI cut short, along with every argument after it: a chat's multi-line system prompt dropped the approval flags that followed it (#553). The shim is therefore replaced by the program it launches, which receives every argument intact. A batch file aviary cannot read through is still run as is, unless an argument has a line break it would lose: that is refused with an error naming models.cli_definitions.<name>.binary as the way to point aviary at the real executable.

func ShutdownContext

func ShutdownContext(prepare func()) (context.Context, func())

ShutdownContext returns a context that is canceled by the first shutdown signal, giving aviary a chance to stop its subprocesses in order. The first signal runs prepare, when given, before the context is canceled, so work that must happen while subprocesses are still alive (the shutdown checkpoint, issue #741) finishes first. A second signal means "now": every owned subprocess is killed and aviary exits immediately, even mid-prepare, so an impatient second Ctrl-C cannot leave an orphan behind.

func Start

func Start(cmd *exec.Cmd) error

Start starts cmd as an owned subprocess: it runs in its own process group so the processes it spawns are terminated with it, it is tracked so aviary kills the whole tree before exiting, and the kernel is asked to tear it down should aviary die without running any cleanup at all.

On platforms where the kernel guard can only be installed on a process that already exists, the child is created in a state where it has not run yet and adoptOrphanedProcess releases it; a child that cannot be released is killed rather than handed back to the caller suspended forever.

func Stop

func Stop(cmd *exec.Cmd) error

Stop terminates a tracked child's process tree and reaps it, asking politely first so the child can shut itself down cleanly.

func Wait

func Wait(cmd *exec.Cmd) error

Wait waits for a tracked child and stops tracking it.

A child that exits while something it started still holds its output pipes leaves Wait waiting on them until cmd.WaitDelay expires, which it reports as exec.ErrWaitDelay. Those leftovers, typically a background shell the agent launched, would otherwise keep running unowned, so the rest of the child's process tree is killed then and the reaped PIDs are logged (#1122).

Types

This section is empty.

Jump to

Keyboard shortcuts

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