supervisor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 10 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 supervisor runs handler processes in their own process group so a timeout or cancel kills the whole tree with kill(-pgid) (RFC 4.2, 6.7).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GroupAlive

func GroupAlive(pgid int) bool

GroupAlive reports whether any process in the group still exists.

func KillGroup

func KillGroup(pgid int)

KillGroup sends SIGTERM then SIGKILL to the process group.

Types

type Outcome

type Outcome struct {
	ExitCode       int
	TimedOut       bool
	OutputExceeded bool
	Cancelled      bool
	Stdout         []byte // only kept when OnLine is nil
	Stderr         string
	Err            error
	Duration       time.Duration
}

Outcome is how the process ended.

func Run

func Run(ctx context.Context, s Spec) Outcome

Run starts the process and waits for it.

type Spec

type Spec struct {
	Argv      []string
	Dir       string
	Env       []string
	Stdin     []byte
	Timeout   time.Duration
	MaxOutput int64
	// OnStart is called with pid and pgid right after start.
	OnStart func(pid, pgid int)
	// OnLine receives every stdout line (without the newline).
	OnLine func([]byte)
	// IdleGrace: after a machine sleep, a run past its deadline is killed
	// only if it produced no output in the last IdleGrace (RFC 8.4).
	IdleGrace time.Duration
}

Spec describes one process.

Jump to

Keyboard shortcuts

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