Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

processes

Programs declared with session_process: running state, start time and last exit.

Declare programs with session_process: it sends these actions and exposes each field as a signal. Read mantle.processes directly to see every declared program in one table.

text {
    content = mantle.processes:map(function(processes)
        local recorder = processes and processes.sessions.recorder
        return (recorder and recorder.running) and "● REC" or ""
    end),
}

State

mantle.processes:get() returns ProcessesState, nil before the first push. A field marked ? may be absent.

mantle.processes payload.

FieldTypeDescription
sessionstable<string, SessionProcess>One entry per session_process name; an undeclared name is nil.

SessionProcess

One declared program: its current run, or what is left of its last one.

FieldTypeDescription
exit_code?integerExit status of the last run; nil while running, before any run, or when a signal killed it.
pid?integerProcess id, also its process group id; kept after exit, nil before a spawn or after a failed start.
runningbooleanWhether it is up now. Otherwise the fields below describe the last run.
start_errorstringWhy the last start failed to spawn, e.g. a cmd not on PATH; empty when it spawned.
started_at?integerUnix seconds when the run began; nil before a spawn or after a failed start.

Actions

Call each as mantle.processes:<action>(arguments...); ? marks an argument you may omit.

ActionArgumentsDescription
declarename: string, stop_signal?: SignalNameRegisters name (required before start) and sets its stop signal, default TERM. Redeclaring updates the signal without touching a running program.
startname: string, cmd: string, args?: string[]Runs cmd with args (no shell) as its own process group. No-op while running or when name is undeclared.
signalname: string, signal: SignalNameSends signal to the program’s process (not its group); no-op when not running.
stopname: stringSends the declared stop signal to the process group, then KILL if it is still up 5 s later; no-op when not running.

SignalName

A signal name without the SIG prefix.

One of "TERM", "INT", "HUP", "QUIT", "USR1", "USR2", "KILL", "STOP", "CONT".

Backend

The Supervisor spawns and owns each program, so it outlives reloads and Renderer replacement. One task per program holds its child and sends every signal, so a signal never reaches a recycled pid. When to use process.run or process.detach instead: processes.

Source: supervisor/src/capabilities/processes/