ProcessTree
Stopping everything an agent started.
A process-group kill is not enough: both Claude Code’s Bash tool and Codex
start each command in a new session with its own process group. So every
agent process gets a unique EFFECT_AGENT_PROCESS variable, which
everything it starts inherits, and a sweep signals every live process
carrying it (Linux, via /proc).
Elsewhere, or for a command that clears its environment, only the agent’s
own process group is reached. A cgroup Launcher (systemd-run --scope)
closes that gap.
Since v0.1.0
Constants
Section titled “Constants”markerVariable
Section titled “markerVariable”The environment variable that marks an agent process and everything it starts.
Signature
declare const markerVariable: "EFFECT_AGENT_PROCESS"Since v0.1.0
Constructors
Section titled “Constructors”newMarker
Section titled “newMarker”A fresh, unique value for markerVariable.
Signature
declare const newMarker: () => stringSince v0.1.0
Predicates
Section titled “Predicates”isAlive
Section titled “isAlive”Whether a process is running (ours or not).
Signature
declare const isAlive: (pid: number) => booleanSince v0.2.0
SIGTERM the process group of pid (when given) and every process carrying
marker (each process gets one SIGTERM), then SIGKILL whatever is left
after grace. Processes they start while stopping (carrying the marker)
are found and stopped too. A no-op once they are all gone.
Signature
declare const kill: ( marker: string, options?: { readonly pid?: number | undefined; readonly grace?: Duration.Input },) => Effect.Effect<void>Since v0.1.0
killNow
Section titled “killNow”SIGKILL the process group of pid (when given) and every process carrying marker, now.
Signature
declare const killNow: (marker: string, pid?: number) => voidSince v0.1.0
markedProcesses
Section titled “markedProcesses”Live processes whose environment carries EFFECT_AGENT_PROCESS=<marker> (Linux; elsewhere none).
Signature
declare const markedProcesses: (marker: string) => Array<number>Since v0.1.0
signal
Section titled “signal”Send a signal to a process (or, with a negative id, a process group). False when it is gone.
Signature
declare const signal: (pid: number, sig: NodeJS.Signals | 0) => booleanSince v0.2.0