Expand description
Process supervision for the agent and MCP children this installation owns, and for its API server: the one place that spawns, identifies, probes and stops them.
§Spawning
spawn_supervised is the only sanctioned way to start a child, and
mark_child stamps it with the environment markers that later prove it
is ours. Every spawn runs on one dedicated thread, which on Linux also arms
the parent-death signal.
§Control
is_running, owns, pids_listening_on, terminate_gracefully,
terminate_group_gracefully and stop_owned are async and never block
a runtime worker. A stop signals only a pid that is provably ours: the pid
the registry recorded and a matching ChildKind marker read back from
the live process. Outcomes are typed (Termination, StopOutcome);
failures are SupervisionError.
§Identity
The environment markers and the pure parsers that read them back live in
systemprompt_models::subprocess; the platform probes here
(live_pid_is_subprocess, is_zombie) execute them against /proc
or sysctl. They are blocking primitives; async callers use owns and
is_running.
§Platform support
The two halves of supervision have different reach, and conflating them is what stranded ports on macOS:
- Identity and reap checks (
live_pid_is_subprocess,is_zombie) work on Linux, via/proc, and on macOS, viasysctl(KERN_PROCARGS2)andproc_pidinfo. Report the platform’s coverage withidentity_verification_supported; where it is absent the checks are fail-closed stubs that never confirm an identity, so no process is ever signalled on a guess. - Parent-death prevention is
prctl(PR_SET_PDEATHSIG)and therefore Linux-only. macOS has no equivalent that survivesexecve, and the kqueue and pipe-EOF alternatives all require cooperation from the child binary — which is an arbitrary MCP server or agent executable here. ASIGKILLed supervisor on macOS therefore leaves its children reparented tolaunchdand still holding their ports; the identity check above is what lets the next start reclaim them instead of erroring out.
Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.
Enums§
- ApiServer
Stamp - How
stamp_api_serverreturned instead of re-executing. - Child
Kind - Which kind of supervised process a pid is claimed to be; selects the
marker variable that names it.
Apiis the API server, stamped bystamp_api_serverrather than spawned. - Stop
Outcome - How a stop of a recorded, marker-verified child ended.
- Supervision
Error - Why a supervision call could not establish or change a process’s state.
- Termination
- How a termination request ended.