runon

Manual · runon 0.1

The engine-room manual

runon reads the process table once, finds what Claude Code, Codex and OpenCode started, works out whether anything still holds each tree, and stops exactly the ones nobody does. It never guesses by process name and it never signals an agent.

1Install

curl -fsSL https://blackman99.github.io/runon/install.sh | sh

The script picks the binary for your OS and CPU from the latest release, checks it against checksums.txt, and puts it in ~/.local/bin. Set RUNON_BIN=/usr/local/bin to install elsewhere, or RUNON_VERSION=v0.1.0 to pin.

SystemTarget in the archive name
Linux x86_64 / arm64x86_64-unknown-linux-musl · aarch64-unknown-linux-musl (static, .tar.gz)
macOS arm64 / x86_64aarch64-apple-darwin · x86_64-apple-darwin (.tar.gz)
Windows x86_64 / arm64x86_64-pc-windows-msvc · aarch64-pc-windows-msvc (.zip)

Archives are named runon-v0.1.0-<target> and hold the binary, the README and the licence.

From source, with Rust 1.95 or newer: cargo install --git https://github.com/Blackman99/runon.

2Usage

Try it without an agent first. runon demo starts three throwaway sessions (two Claude Code, one Codex) with real child processes and fake session logs under your temp directory, then scans them:

runon demo            # a small, real mess
runon                 # scan: what outlived its agent
runon stop --dry-run  # what would be signalled
runon stop --demo     # clean the demo up

On a real machine the loop is the same: run runon after an agent session, read the why line, then runon stop. It asks once before sending anything. In scripts, pass --yes.

Let the session clean up after itself

Claude Code runs a SessionEnd hook when a session closes. runon hook claude prints one; merge it into ~/.claude/settings.json or a repo's .claude/settings.json:

{
  "hooks": {
    "SessionEnd": [
      { "hooks": [ { "type": "command", "command": "runon stop --hook", "timeout": 15 } ] }
    ]
  }
}

The hook reads the session id from stdin and stops only what that session started, attached or not. /clear also fires SessionEnd; runon ignores it, so your MCP servers survive a clear.

3How it decides

Coding agents stamp the commands they run with environment variables, and the kernel keeps a process's environment for its whole life. runon reads those stamps, then walks up each process's parents looking for a live harness. Every parent's start time is checked, so a recycled PID is never mistaken for the agent.

AgentStampWhat runon adds from the session log
Claude CodeCLAUDECODE=1 CLAUDE_CODE_SESSION_IDthe Bash call that started it, from ~/.claude/projects/…/<session>.jsonl
CodexCODEX_THREAD_ID CODEX_TOOL_CALL_IDthe exact call, and whether its output is already in ~/.codex/sessions/…/rollout-*.jsonl
OpenCodeOPENCODE=1 OPENCODE_SESSION_IDthe session (no log lookup yet)
OUTLIVED
No live harness above it. Either the session is over, or the harness killed the shell it ran the command in and the shell's children kept going. That second case is how a stopped background task leaves a dev server behind. runon stop stops these.
RETURNED
Codex only. The harness is still running, but the rollout already holds the output of the tool call that started this tree. It is shown and left alone unless you pass --returned, because Codex may still be talking to it.
LIVE
Still attached to a running agent. Listed with --all, never stopped by default.

Rows also carry tags: HOT (50% of a core or more), BIG (500 MB resident or more), MCP (looks like an MCP server) and DEMO (started by runon demo).

What a stop does

  1. Shows the trees and asks once (or not, with --yes).
  2. Sends TERM to the deepest child first, then up the tree.
  3. Waits the grace period (3 s), then sends KILL only to what is still there.
  4. Before every signal, checks the PID still belongs to the same process. It refuses to signal an agent harness or its own parents.

4Config

There is no config file. Everything is a flag or an environment variable.

SettingDefaultEffect
CLAUDE_CONFIG_DIR / --claude-home P~/.claudewhere Claude Code session logs are read from
CODEX_HOME / --codex-home P~/.codexwhere Codex rollouts are read from
NO_COLOR / --no-colorcolour on a terminalplain text output
COLUMNS100output width, from 60 to 160
--grace SECS3wait between TERM and KILL

5Reference

Commands

runonScan. Lists OUTLIVED and RETURNED trees. Add --all for LIVE ones, --json for machines.
runon stopStop OUTLIVED trees, after asking.
runon demoStart three fake sessions with real child processes and scan them. The children exit by themselves after ten minutes.
runon hook claudePrint the Claude Code SessionEnd hook.
runon versionPrint the version.

Stop flags

--dry-runShow what would be stopped, signal nothing.
--yesDo not ask. Required when stdin is not a terminal, otherwise stop refuses before signalling.
--returnedAlso stop RETURNED trees.
--session IDEverything one session started, attached or not. A unique prefix is enough.
--pid NThis process and its children, even if unstamped. Still refuses harnesses.
--grace SECSSeconds between TERM and KILL.
--demoEnd what runon demo started and delete its temp folders.
--hookHook mode: read {"session_id": …, "reason": …} on stdin, stop that session's trees, stay silent on clear.

Exit codes

0nothing outlived its agent (or the stop finished cleanly)
3strays found. Handy in CI: runon || echo "something is still running"
1error
64usage error

6JSON

runon --json prints one object. This is a trimmed row from the demo on Linux:

{
  "runon": "0.1.0", "scanned": 171, "elapsed_ms": 308, "agent_processes": 6,
  "counts": { "outlived": 2, "returned": 1, "live": 2 },
  "groups": [{
    "verdict": "OUTLIVED", "agent": "claude",
    "session": "1c6bfc7e-a113-4280-a745-a573dcb1afbb",
    "command": "npm run dev -- --port 5173",
    "pids": [2418516, 2418520], "cpu": 0.0, "rss_bytes": 4792320, "age_secs": 3,
    "tags": ["DEMO"], "harness_pid": null, "session_harness_pid": null,
    "origin": { "tool": "Bash", "command": "npm run dev -- --port 5173",
                "background": true, "call_id": "toolu_01Demo8DevServer",
                "at": "2026-10-23T02:40:31Z", "returned_at": "2026-10-23T02:40:31Z" },
    "cwd": "/tmp/runon-demo-27762f71/shop"
  }]
}
pidsthe tree, root first
harness_pidthe live agent above this tree, if any
session_harness_pida live agent process for the same session elsewhere (the session is open but no longer holds this tree)
originthe tool call from the session log, when found; null otherwise
cpupercent of one core, summed over the tree, measured over about 0.3 s

runon stop --json prints {"stopped": [...]} with a result per tree: term, kill, gone or failed.

7FAQ

Will it kill my agent?

No. Processes named like a harness (claude, codex, opencode) are never signalled, nor is anything in runon's own parent chain, even with --pid.

Why not just pkill node?

Because the dev server you started yourself is also node. runon only looks at processes carrying an agent's stamp, so your own terminals are invisible to it.

Does it send anything anywhere?

No network at all. It reads the process table and the session logs already on your disk, and prints.

Windows?

Scanning works the same. Windows has no TERM, so a stop is a hard TerminateProcess after the same checks; processes get no chance to clean up. The conhost.exe every console program gets is left out of the trees.

Cursor, Aider, Gemini CLI?

Not yet. runon needs a stamp the agent puts on its child processes; if your agent sets one, open an issue with env output from inside a tool call and it can be added.

A process says OUTLIVED but I still want it.

Leave it. runon only reports unless you run stop, and stop always lists what it will signal before asking. --dry-run never signals.

What if a PID was reused?

Every signal is preceded by a start-time check on that PID. If the process changed, it is skipped and reported as gone.