Skip to content

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

The environment variable that marks an agent process and everything it starts.

Signature

declare const markerVariable: "EFFECT_AGENT_PROCESS"

Source

Since v0.1.0

A fresh, unique value for markerVariable.

Signature

declare const newMarker: () => string

Source

Since v0.1.0

Whether a process is running (ours or not).

Signature

declare const isAlive: (pid: number) => boolean

Source

Since 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>

Source

Since v0.1.0

SIGKILL the process group of pid (when given) and every process carrying marker, now.

Signature

declare const killNow: (marker: string, pid?: number) => void

Source

Since v0.1.0

Live processes whose environment carries EFFECT_AGENT_PROCESS=<marker> (Linux; elsewhere none).

Signature

declare const markedProcesses: (marker: string) => Array<number>

Source

Since v0.1.0

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) => boolean

Source

Since v0.2.0