process

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package process manages background processes started by run_command with background=true.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandStarted

type CommandStarted struct {
	ID        string
	Command   string
	SessionID string
	StartedAt time.Time
	// contains filtered or unexported fields
}

CommandStarted represents a running background process.

type ExitEvent

type ExitEvent struct {
	ID           string
	Command      string
	SessionID    string
	ExitCode     int
	Reason       ExitReason
	TimeoutSec   int
	FormatOutput func() string
}

type ExitReason

type ExitReason string
const (
	ExitReasonCompleted ExitReason = "completed"
	ExitReasonError     ExitReason = "error"
	ExitReasonTimeout   ExitReason = "timeout"
	ExitReasonKilled    ExitReason = "killed"
)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager tracks background processes.

func NewManager

func NewManager(maxProcs int, outputOptions cmdoutput.Options) *Manager

NewManager creates a new process Manager. maxProcs limits concurrent background processes (0 = unlimited).

func NewManagerAtRoot

func NewManagerAtRoot(maxProcs int, outputOptions cmdoutput.Options, workspaceRoot string) *Manager

func (*Manager) Kill

func (m *Manager) Kill(id string) error

Kill terminates a background process. Sends SIGTERM, waits 500ms, then SIGKILL.

func (*Manager) KillAll

func (m *Manager) KillAll()

KillAll terminates all running background processes.

func (*Manager) List

func (m *Manager) List() string

List returns a formatted list of background processes for the current session.

func (*Manager) Read

func (m *Manager) Read(id string) (string, error)

Read returns output accumulated so far for a running background process.

func (*Manager) Remove

func (m *Manager) Remove(id string)

Remove cleans up a finished process entry.

func (*Manager) SetExitHandler

func (m *Manager) SetExitHandler(handler func(ExitEvent))

SetExitHandler sets a callback invoked when a background process exits. The callback should append a system signal to the loop.

func (*Manager) SetLimits added in v0.0.2

func (m *Manager) SetLimits(maxProcs int, outputOptions cmdoutput.Options)

func (*Manager) SetSessionProvider

func (m *Manager) SetSessionProvider(provider func() string)

SetSessionProvider sets a callback used to tag newly started background processes with the session that launched them.

func (*Manager) Start

func (m *Manager) Start(command string, timeoutSec int) (string, error)

Start launches a background process and returns its ID.

Jump to

Keyboard shortcuts

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