Skip to content

Running the daemon

This page holds what a -serve daemon does off the JSON-RPC wire. The flags are under Daemon lifecycle (flags).

A rule with no mark matches the reference as measured on 5fd08069 or on an earlier build. A build that a section names in its first lines holds for that section. The other marks are those of the protocol reference.

Common tasks

Start the daemon

  1. Run the binary with -serve, -socket and a token source (flags).
  2. Wait for the launcher (launcher wait).

Stop the daemon

  1. Run the binary with -stop (-stop).
  2. After a failed connect, -stop removes daemon.token unless it prints survivor (token).

Find the log

  1. Open remote-server.log in the socket directory (log).

Find and rotate the token

  1. Read daemon.token in the socket directory (token).
  2. Stop the daemon. Start a new one with the new token (token source).

Recover after a crash or a stale lock

  1. Restart the daemon (launcher).
  2. On Linux and macOS, wait for the reap of children (reap).
  3. If the log says [daemon] serve: WARNING … (its holder is not a daemon (role "")), a non-daemon process holds daemon.lock (no signal).

Read the cleaner's lines

  1. Find the [hostclean] lines and the [daemon] host cleaning off line in the log.
  2. host cleaning off means no pass runs (runs).
  3. was not retired means the cleaner did not retire that daemon, and its reason says why (signals).

Token persistence (daemon.token)

Transport gives the mode of the socket. With daemon.token a client can reconnect and authenticate after the -token-file was unlinked, or after the -token-fd pipe closed.

Once the socket is listenable, the daemon writes its in-memory token to daemon.token in the socket directory, with mode 0600. The write is atomic: a daemon.token-* temp file and a rename. A failed write logs [daemon] failed to persist token: …, and the daemon serves on. A new daemon replaces a dead daemon's token only after its reap, its bind and its listen, and until then the file holds the old token (measured on Linux).

The daemon unlinks the file only on a graceful stop: server.shutdown, SIGTERM, SIGINT or its self-exit. A SIGKILL or a crash leaves it. -stop also removes it after a failed connect, unless it prints survivor (see -stop). The unlink tests identity (os.SameFile). A file at the path that the daemon did not write stays, so a departing daemon keeps the successor's token (measured on Windows, from the code on Linux and macOS). The same guard covers rpc.sock on Linux and macOS and the rpc.pipe pointer on Windows. A token or pipe pointer with no recorded identity stays. A socket with no recorded identity goes with a plain unlink (both claustrum's own).

Two states remove a successor's socket, as on the reference:

  • On Linux ext4 the new socket can get the old one's inode. The old daemon then removes it as its own (measured on Linux).
  • On Windows, after a take-over, the old daemon's stop removes it (measured on Windows).

The fixed name and the socket folder are the reconnect contract, so they are not configurable. On Windows 0600 is not an owner-only DACL, a limit of os.CreateTemp in Go. The per-user session folder is the confinement, and claustrum does not "fix" this parity caveat. On Linux and macOS the run-dir lock evicts a prior live daemon of the same socket before the new one binds. Two daemons still collide on this file where an eviction is refused, and on Windows.

Run-dir lock (daemon.lock)

The lock exists on Linux and macOS only. It is a file beside the socket, off the JSON-RPC wire. A rule of this section without a mark is measured on Linux. A rule marked "also macOS" is measured on macOS too. The lock is parity with 4534d86, not a claustrum fix.

Before it binds the socket, a -serve daemon takes an exclusive flock on daemon.lock in the socket directory (mode 0600). It writes an owner record, a JSON object, into the file. Both forms are measured on macOS too. Until the reap of its start ends, the record is {"pid":<n>,"role":"serve","node":"<node>"}. After the reap and the bind, it is {pid, role, node, instanceId, startedAt}, with the instanceId of the listening line and the instanceId and startedAt that server.capabilities answers. The startedAt match is measured on macOS too. From the code: node is the boot id joined to the pid-namespace inode on Linux, and sysctl kern.bootsessionuuid on macOS, and the record has no node if that identity is unknown.

On a graceful stop the daemon removes its own rpc.sock, kills its child groups and then removes daemon.token (see What the stop does). Last it truncates the record and releases the lock. daemon.lock stays, empty.

Eviction of a live holder

A rule here without a mark is measured on Linux.

A prior live daemon of the same socket can hold the lock. The new daemon sends it SIGTERM and tries the lock every 50 ms for 2 s. If the lock is still held, it tests the holder again and sends SIGKILL. Then it tries the lock for 1 s more (claustrum's own value). It waits on the lock, not on the pid. On Linux both signals go through one pidfd_open descriptor with pidfd_send_signal. On macOS claustrum uses kill (the call of the reference there is not measured).

The daemon logs these lines, where <who> is pid <n> (instance "<hex>") for a holder with the full record and pid <n> for the short record. The first two lines, in the pid <n> form, are also macOS.

[daemon] serve: run dir is held by a live daemon, <who>; sending SIGTERM
[daemon] serve: previous daemon <who> exited after SIGTERM
[daemon] serve: WARNING previous daemon <who> ignored SIGTERM for 2s; sending SIGKILL (its Claude Code children, if any, are ended next, before this daemon serves)
[daemon] serve: previous owner of <dir>: killed

The summary line [daemon] serve: previous owner of <dir>: <outcome> ends in terminated after a SIGTERM, in killed after a SIGKILL, and in survivor for a holder that stays. A holder that the SIGKILL stopped gets no "exited" line.

A signal can reach a daemon during its own start, for example from a second daemon or from -stop. The daemon handles one SIGTERM or SIGINT and logs one line, for example [daemon] received terminated; shutting down (children will be killed), or received interrupt with the same tail. It finishes the reap of its start. A daemon in the eviction of an older holder still evicts it. It sends the child of that holder SIGTERM before it binds. Then it binds, listens, writes its token, shuts down and exits 0. For a SIGTERM from a second daemon these rules are also macOS. A -stop during the reap prints terminated and exits 0. The launcher of the signalled daemon exits 1 after about 12 s in two cases: a signal during an eviction, and a -stop during the reap. Its text is daemon did not take over <socket> (predecessor still owns it). A second daemon that sent SIGKILL to a first one during its start takes the lock and serves with its full record.

Holders that get no signal

A rule here without a mark is measured on Linux.

The eviction fires only against our own -serve daemon for this socket, on this machine. If the first test of the holder fails, the daemon signals nothing and serves without the lock. It logs a refusal line and, except for an unusable record, the summary survivor. claustrum refuses a holder on another machine or container that shares the folder, a holder with an unknown machine identity, and a holder that is not its serve process for this socket. For these three refusals both texts are claustrum's own. A holder that survives SIGKILL stays, with the summary survivor (from the code).

If the second test of the holder fails, right before the SIGKILL, the daemon treats the holder as gone. It logs [daemon] serve: pid <n> is no longer our serve holder before SIGKILL (<reason>); treating the previous daemon as gone and the summary terminated, and tries the lock once more. Normally it then serves with the lock.

A holder whose record has the role stop gets no signal. The daemon tries the lock every 50 ms for 2 s. Then it logs this line and serves without the lock (also macOS):

[daemon] serve: <dir>/daemon.lock is held by a --stop (pid <n>) that has not let go; leaving it

A process that is no daemon can hold the lock, with no owner record. The daemon signals nothing and logs three lines:

[daemon] serve: WARNING <dir>/daemon.lock is held by a live process we will not signal (its holder is not a daemon (role "")); leaving it alone
[daemon] serve: previous owner of <dir>: survivor
[daemon] serve: not the run dir's lock holder; leaving any predecessor's children alone and recording none

claustrum logs the third line at every start that ends without the lock (claustrum's own beyond this case, not measured). Such a daemon reaps and records no children. Other role texts are not measured.

The late lock

A rule here without a mark is measured on Linux.

While another process holds the lock, the daemon tries it again every 30 s (measured for a holder of an empty file, also macOS). A failed try logs nothing. A good try writes the full record, holds the lock until the exit and logs this line (also macOS):

[daemon] run-dir lock acquired late (previous holder gone); recorded pid <n> (instance "<hex>")

claustrum also tries again in every other case where another process keeps the lock (claustrum's own). It does not try again after a failed open of the file or a refused lock call.

Windows and macOS

Windows has no run-dir lock (measured on Windows). The remove-then-rebind handoff of the socket keeps two daemons apart there, and the "not the run dir's lock holder" line above is the first log line of every start (measured on Windows).

On macOS claustrum verifies the holder through sysctl KERN_PROCARGS2 before it signals it, in the eviction and in -stop. The reference skips that test (measured on macOS). See D15.

Host cleaner (off-wire, Linux and macOS)

A periodic sweep ends orphaned Claude Code process groups, retires abandoned daemons and tidies stale run dirs. It reaches no JSON-RPC frame. A rule with no mark was measured against 89cb6289 on Linux. A rule that names macOS was measured on macOS against 89cb6289. A rule marked 5fd08069 or f6010b97 was measured against that build.

claustrum links no cleaner on Windows. The Windows references logged no cleaner line and changed nothing, in a check with no positive control.

When the cleaner runs

The cleaner is on in one case only. The socket path is cleaned first: . and double slashes drop out, and .. is resolved by text (from the code for ..). The cleaned path is absolute, and its last three components read run/<id>/rpc.sock, with that exact case. The folder above run is the root. The resolved daemon binary is <root>/srv/<id>/<name>, one folder below srv, under that root or under the symlink-resolved form of that root. The first pass then runs 15 s after the start. In every other case the cleaner is off and runs no pass, and the daemon logs one of two lines right after the listening line:

[daemon] host cleaning off: socket path "<socket>" is not <root>/run/<id>/rpc.sock
[daemon] host cleaning off: executable "<binary>" is not a deployed daemon under <root>/srv

The socket line names the socket as given. The executable line names the resolved binary and the root's srv as given. A symlink to run with another name turns the cleaner off with the socket line. macOS gave the same decisions where it ran.

A path through a symlink to the root or to a folder above it keeps the cleaner on, for the socket and the binary. If the daemon cannot read its own executable path, the binary test does not run (not measured).

A pass acts on the root as the socket path gives it and on its resolved form, the same folder under its real path. It never acts on the root of the binary. If the resolution fails, it acts on the root as given only (not measured). A pass lists each run folder once, and its lines name each in the spelling of the socket as given.

On Linux a CLAUDE_SSH_RUN_FROM place that the place check accepts adds an extra root, as on 13047a51 (measured). It is <root> of <root>/srv/<rev>/server, and its resolved form (claustrum's own, not measured). The daemon binary there keeps the cleaner on, and 87375cc7 logs the executable line instead. A pass of 13047a51 then ends a stream-json orphan directly in the ccd-cli of the own root or the place root (measured). It spares a binary in ccd-cli/<version>/, one with no stream-json, other processes of the place root, its srv daemons, other roots and a second home (measured). The run dirs and the stamp test use the socket root only (claustrum's own, not measured). macOS takes no place root (not measured).

A long run root

On Linux the cleaner dials a socket path over 107 bytes through /proc, as the daemon does (A long socket path). So the pass runs at a long root, with the guards of a short one. The maintainer approved acting at a long root on 2026-11-01. be1c1ca5 at a 120-byte socket path on Linux (measured):

  • A live peer in a run dir 40 days old stays (too young to judge) and gets no signal.
  • A dead run dir stays if a process holds its daemon.lock or if it is 10 days old.
  • A free dead run dir 40 days old goes, with the removed run dir line.
  • Orphaned groups end as at a short root: SIGTERM, then SIGKILL after 3 s for a group that ignores it.
  • An idle sibling daemon in a run dir 40 days old gets SIGTERM through a pid descriptor, and its run dir goes.

A long sibling socket under a short root gets the same verdicts (from the code). With no usable /proc, and on macOS, a long socket reads as inconclusive, and a long own socket stops the pass (claustrum's own, not measured). macOS at a long path is not measured.

Signals of the cleaner

A stranded daemon is a daemon whose socket path no longer leads to it. On Linux 87375cc7 and 13047a51 send one SIGKILL through a pid descriptor to one whose socket folder is gone and that holds no daemon.lock (measured). claustrum tests its identity first. Its other group members then get SIGTERM, and one that still runs 3 s later gets SIGKILL (measured). It precedes the orphan groups, and the summary counts it:

[hostclean] ending stranded daemon pid <pid>: it was started for "<socket>", which no longer leads to it, and it holds no run-dir lock: SIGKILL
[hostclean] ending process <pid> left behind by stranded daemon <pid>: SIGTERM
[hostclean] process <pid> outlived SIGTERM for 3s: SIGKILL

Both builds end a stranded daemon and a flat ccd-cli orphan from 5 minutes of age: 300 s ended, 270 s spared (measured on Linux, not finer than 30 s). They spared a real daemon that held daemon.lock, with its run folder or only rpc.sock gone (measured on Linux). The other gates are claustrum's own, not measured: the daemon binary, a run-dir socket of the root, the daemon-child marker and no client. claustrum ends one with no lock and only rpc.sock gone, and spares a stopped daemon, a socket that refuses or cannot be probed, and a child that leads its own group (not measured). On macOS both builds sent no signal to a stopped stranded daemon (measured), and claustrum sends none. A daemon that the cleaner leaves ends by itself, except at a long socket path (Orphan-exit self-probe).

The cleaner retires an abandoned daemon with SIGTERM: a daemon on a run dir that is idle past the threshold, or whose name carries .removing- from an earlier removal. A listener that is not the daemon binary, or that serves another socket, gets no signal. On macOS only the first case is measured. This gate is parity, not D15. A daemon that is too young is not retired. The run dir gets this line (measured on macOS for a daemon about 33 s old). The age of 5 minutes is claustrum's own:

[hostclean] run dir "<dir>" unused for <n> days: its daemon (pid <pid>) was not retired: it is too young to judge

On Linux the cleaner opens a pid descriptor before its last identity test and signals through it with pidfd_send_signal, as on the reference. So a pid that changes hands after that test gets no signal (from the code). Without that call claustrum uses kill, and the stranded step sends nothing (not measured). macOS uses kill, and both cleaners end the same daemons and groups and remove the same folders there. The signal call of the macOS reference is not measured.

On Linux (5fd08069) a stopped daemon on an idle run dir:

  • gets no SIGTERM, and the dir stays
  • gives the run dir the was not retired line with the reason the listener could not be verified as a daemon of ours (not inspectable)
  • gets this line too if it is past claustrum's own age of 5 minutes, and counts as undecided:
[hostclean] daemon pid <pid> left alone this pass: it could not be inspected (or is stopped)

The lsof reads (macOS)

Every rule of this sub-section holds on macOS, unless it names Linux. Linux runs no lsof and logs neither left alone this pass line below (from the code). The cleaner asks lsof three things:

  • whether a daemon it is about to retire still has a live client
  • whether the stdio of an orphan is three pipes
  • whether a process holds the daemon.lock of an idle run dir

Each run has a command deadline, and the cleaner gives up on a run that outlives a later bound. Both bounds are claustrum's own. The outcomes of a run:

lsof outcome busy read of a daemon lock read of a run dir
the command does not start, or the run writes to stderr and exits 1 the daemon gets no SIGTERM a dir with a lock file stays
the cleaner gives up on the run no SIGTERM, the was not retired line and no left alone line (5fd08069) kept (claustrum's own)
the deadline ends the run no SIGTERM (5fd08069) kept (5fd08069)
the run completes with nothing on stderr the output decides the output decides

The exit code is no rule. When no process holds the file, lsof exits 1 with no text, and the dir then goes. claustrum reads every run that writes to stderr as no answer, whatever its exit code and stdout. Of those runs, only exit 1 with no stdout is measured. After a run that it gave up on, claustrum runs no more lsof for the daemon. Its pass then ends after one 17 s wait for that daemon, as on be1c1ca5 and b3081b51 (measured on macOS, D17, retired).

When the busy read of a daemon gets no answer, the pass logs these two lines and counts the daemon under candidates left undecided. The first line comes before every run dir line:

[hostclean] daemon pid <pid> left alone this pass: its open files could not be inspected
[hostclean] run dir "<dir>" unused for <n> days: its daemon (pid <pid>) was not retired: a connection is attached to it right now, or that could not be read: in use after all

The first line goes only to a daemon that is past claustrum's own age of 5 minutes and serves an idle run dir, once for each such daemon. With more than 4096 processes claustrum prints no such line (from the code). On Linux and macOS the second line also comes for a daemon that still has a client (measured against f6010b97). On Linux it also comes for a daemon whose connections could not be read (from the code).

When the stdio read of an orphaned Claude Code group gets no answer, the cleaner does not signal the group. It logs this line after the daemon line and before the run dir lines, and counts the group as undecided:

[hostclean] process group <pgid> left alone this pass: its descriptors could not be inspected

With a working lsof the cleaner ends the group. A run that the cleaner gave up on spares the group with claustrum's own line. On Linux the same line comes when /proc/<pid>/fd of the group cannot be read (from the code). On macOS it comes when a completed lsof run lists no file of the group (from the code):

[hostclean] spared process group <pgid> this sweep: its open descriptors were unreadable

The lock of an idle run dir

On macOS these states of the daemon.lock of an idle run dir keep the dir, with the line [hostclean] run dir "<dir>" unused for <n> days: kept, its daemon.lock could not be examined:

  • the lsof command does not start, or the run writes to stderr and exits 1, and the dir has a daemon.lock that is empty, holds the record of a dead daemon, or that a live process holds. Any other content takes the same arm (from the code)
  • the daemon.lock has mode 0000
  • the daemon.lock is a symlink to a regular file, a folder, or a FIFO

On macOS these states keep the dir with the line [hostclean] run dir "<dir>" unused for <n> days: kept, a live process holds its daemon.lock:

  • another live process, or the cleaner and a child of the cleaner, holds the lock file open

On macOS the dir goes in these states:

  • the dir has no daemon.lock, also when lsof does not start or writes to stderr and exits 1. No lsof runs then (from the code)
  • only the cleaner itself holds the lock file open
  • the lock holds no record (text, {}, or the first half of a record), and no process holds it
  • the lock holds the record of a live pid that does not hold the file
  • the lock holds the record of a dead pid, and no process holds it

A second pass is not measured on macOS.

On Linux a lock that cannot be opened, a lock that is no regular file, and lock content that is no record keep the dir, with claustrum's own line [hostclean] run dir "<dir>" kept: whether a process holds its run-dir lock could not be determined. On Linux an empty daemon.lock is not such content: the dir goes when no live process holds it. On Linux (5fd08069), when /proc/locks cannot be read, a dir whose daemon.lock is a regular file, empty or with a record, stays with the could not be examined line, also when a process holds the lock.

Passes, orphans and stale run dirs

These rules are read from claustrum's code, except where a bullet names the reference.

  • After the first pass, one pass runs each day. The cleaner acts only on this user's own processes, on the run, srv and ccd-cli folders of its own root, and on the ccd-cli folder of an extra root. A pass acts only after it confirms that its own socket still leads to itself.
  • An orphan is a stream-json daemon child that leads its process group. It has parent pid 1 and three pipes for stdio. Its binary sits directly in <root>/ccd-cli of either root, or it carries a CLAUDE_SSH_CHILD stamp of its own pid and start. A stamped orphan also needs any CLAUDE_SSH_RUN_DIR entry of a run dir under the root, a gone daemon's too (both c9125eb8, on Linux and macOS). A text test spares a deeper path, and a stopped stamped orphan without that entry is skipped silently (claustrum's own, not measured). Its group gets SIGTERM, and SIGKILL 3 s later if a member is left (c9125eb8 for a gone leader, on Linux). In the settle after the SIGKILL this wait is claustrum's own, not measured. A young orphan stays. An ambiguous orphan is spared and logged.
  • A stale run dir is idle past 30 days, or its name carries .removing-. Its socket does not answer, and no live process holds its lock. The pass reads each run dir's idle age before it dials any daemon, because a dial writes a line to that daemon's log. It skips its own run dir and every entry that is not a plain directory, a symlink included. It reads the idle age again before it probes a dir, and it keeps a dir that came back into use, unless the dir has a staging name. It renames a stale dir to <name>.removing-<own pid>-<base-36 time> inside the run root and then removes it. If a socket appears after the rename, or the lock becomes held or unreadable, it renames the dir back. A dir whose daemon it retires goes in the same pass, once that daemon's socket is gone. A dir it cannot probe conclusively stays.
  • "Busy" is a 3 s sampling window, not a state. A daemon that is idle across the window and gains a client a moment later still gets SIGTERM.
  • The limit lines are four: more than 4096 processes, more than 64 orphan groups, more than 64 run dirs, and 8 retire attempts in one pass. claustrum counts attempts there, refused ones included. The reference count after a refused attempt is not measured. The log lines carry the [hostclean] prefix after claustrum's level tag. All four limit lines, the line before a SIGKILL, the reason for a held lock, and two reasons for a listener that is not our daemon, not our daemon binary and not serving that socket, use the texts of the reference (measured on Linux). So do the line of a socket that cannot be probed and the reason it did not exit within 3s of SIGTERM (13047a51, measured on Linux). The pass-starting line does too (87375cc7 and 13047a51, measured on Linux and macOS). macOS uses the other texts too, measured there only for the held-lock reason and (not our daemon binary).
  • The 15 s delay, the 3 s grace and the limit of 64 groups match the reference. The daily period, the 5 minute age of the other steps, the 30-day idle age and the 3 s busy window are claustrum's own.

Daemon startup (-serve)

The launcher wait and the self-locate are measured against 5fd08069, and the other rules against 89cb6289, on the systems that each rule names.

The launcher is the -serve process that the operator starts. It re-execs its own binary as the detached daemon and waits for it. A refused CLAUDE_SSH_RUN_FROM place exits 78 first (the place check). On Linux a launcher that cannot read /proc/self/exe prints claustrum: locate self: <error> and exits 1 before any write. macOS and Windows re-exec os.Args[0] instead (not measured). On Linux and macOS a launcher with HOME unset or empty prints claustrum: cannot resolve home directory: $HOME is not defined and exits 2. The reference does the same with its own prefix (4c111e86, measured on Linux; macOS from the code). On Windows an unset or empty USERPROFILE exits 2, and the line names %userprofile% (from the code, not measured). The launcher creates a missing socket folder with mode 0700. Windows ignores that mode (from the code). On Linux and macOS a failed create prints claustrum: mkdir <folder>: <error> and exits 1 before the log open. The folder is the one whose mkdir failed. 87375cc7 and 13047a51 print the same line with their prefix and exit 1 for a folder above that cannot be searched: mkdir <folder>: permission denied (measured on macOS). Linux and the other errors are not measured. On Windows the error of the log open follows instead (from the code).

The launcher wait

The launcher connects to the socket path every 50 ms, for 12 s at most. It closes each at once, so the daemon logs a New connection from: @ / Connection closed: @ pair. Claustrum logs neither line for it (Lines of connections). A socket file that refuses the connect does not end the wait. A folder with content at the path does not end the wait either. The daemon does not remove it, so it never binds (measured on Linux and Windows). An empty folder there is removed as an old socket file is (from the code).

  • The predecessor is the daemon that answered on the path before the start. On Linux and macOS, a daemon that answers and is not the predecessor ends the wait with exit 0.
  • On Windows the first connect that works ends the wait, also one that the predecessor answers.
  • At 12 s the launcher exits 1 and prints one of two lines to stderr. A connect that reached the predecessor gives claustrum: daemon did not take over <socket> (predecessor still owns it). Any other wait gives claustrum: timeout waiting for daemon to accept on <socket>.

After exit 0 the socket accepts connections. On success the launcher prints nothing but the Windows breakaway line below. The daemon prints its ready line on its own stdout, which is the daemon log. With no log opened, that stdout is the launcher's stdout (from the code).

A restart on a live socket unlinks the old socket and binds a new one, off the JSON-RPC wire. The departing daemon's half is the identity-tested unlink under Token persistence, and the launcher half is this section.

The bind after the reap (Linux and macOS)

The daemon claims daemon.lock and reaps the recorded children of a dead daemon. Only then does it remove the old socket file, bind, and complete the lock's owner record. So nothing listens on the path while the reap waits for a group. A client connect in that wait fails: with the socket file of the dead daemon there, it gets ECONNREFUSED, and with none, ENOENT. A recorded child that ignores SIGTERM makes the wait about 2 s.

On Windows the daemon also removes the old socket file before it binds.

A long socket path (Linux and macOS)

A socket address holds a path of 107 bytes on Linux and 103 on macOS. be1c1ca5 serves at 120 bytes on Linux and 110 on macOS, and -bridge and -stop reach it (measured). claustrum does the same:

  • Linux binds and dials by the name /proc/self/fd/<n>/<last element> of a handle of the socket folder (measured on Linux).
  • With no usable /proc, it changes to the socket folder, uses the last element and changes back. Linux does so with a stand-in /proc, and macOS always (measured).
  • On Linux a last element of about 91 to 107 bytes is too long for the /proc name. It takes the change of folder (from the code).
  • A last element over the limit fails with listen unix <path>: the socket path is longer than the 107 bytes that this system allows (103 bytes on macOS, measured).
  • SIGTERM and -stop remove rpc.sock and daemon.token as at a short path (measured on Linux).

claustrum's own: the identity test of the /proc name, and the error after a failed change back.

The job of the launcher (Windows)

On Windows the launcher starts the daemon outside the job of the launcher (CREATE_BREAKAWAY_FROM_JOB). So the daemon outlives an SSH session whose job ends its processes. How the reference leaves the job is not measured. If the job refuses breakaway, the launcher starts the daemon inside the job and prints one line on its stderr. 89cb6289 prints this text after a time stamp, and claustrum puts its level tag before it:

[daemon] detached spawn failed (fork/exec <binary>: Access is denied.); retrying without breakaway

Child records and the reap (Linux and macOS)

A daemon that holds the run-dir lock records each process.spawn child in <run dir>/children/<pid>.json, on every socket shape. The run dir is the socket path's folder. The child needs a pid of 2 or more and a start time that the daemon can read. With no usable /proc, the daemon on Linux logs one line, writes no record and makes no children folder (be1c1ca5, measured on Linux). Windows writes no record and reaps none (measured on Windows). Unless a rule says otherwise, the rules below are measured against 89cb6289 on Linux, and a rule that names macOS on macOS.

The record is one JSON object with the members in this order:

{"pid":<int>,"node":"<boot-id>/pid:[<inode>]","host":"machine-id:<hex>","instance":"<daemon instance id>","daemonPid":<int>,"daemonStart":"<start>","argv0":"<child argv0>","start":"<start>","at":<epoch-ms>}

daemonStart and start are strings. They hold clock ticks on Linux and the date text of CLAUDE_SSH_CHILD on macOS. On macOS the node is the boot-session UUID, and the host is the hostname. With a launcher, argv0 is the launcher, and a program member after argv0 holds the command. claustrum writes no program without a launcher (not measured).

  • The daemon writes a record through a temp file children/.rec-<pid>.json.<12 characters> and a rename. The source of the 12 characters is claustrum's own.
  • The end of the child removes its record, before the pipe drain, if the file is a regular file that holds the written start (c9125eb8).
  • Measured on c9125eb8: a changed start keeps the record (Linux and macOS, also with daemonStart changed on macOS). A blank file (macOS) and text that is not JSON (Linux) stay. A link to a copy of the record, inside or outside the run dir, stays (Linux and macOS). A changed node, host, argv0 or at goes (Linux and macOS). A changed instance, daemonStart or pid still goes (Linux). A pid with no record of this daemon gets no remove and no line (Linux and macOS). No case logs a line.
  • claustrum's own, not measured: a changed program goes. A pid with no record through a children symlink gets no remove and no line. A FIFO or a file over 64 KiB stays. An Lstat just before the remove must show the file that was read.
  • A graceful shutdown removes the records of the children that it ends. claustrum waits 1 s at most for them (claustrum's own). On Linux a running child whose sweep SIGKILL, or whose group SIGKILL at the end of the asked wait, failed with EPERM gets no wait. 87375cc7 does so after a refused client KILL and at the end of the asked wait (measured on Linux with server.shutdown). A refused sweep SIGKILL with no client KILL first is claustrum's own, not measured. With -keep-children it removes the records of the children that stay alive, so the next daemon leaves them alone (claustrum's own, as the flag is).
  • A record stays after a kill of the daemon, and for a process whose id a later spawn took.
  • After a rename of the run dir, a record goes under the new name. The daemon holds the run dir open.
  • No record is written through a children that is not a real folder inside the run dir.

The reap

At a -serve start, after the run-dir lock and before the bind, the daemon reads the records:

  • It walks children in directory order and handles the first 128 names that end in .json. The rest wait for the next start. Kept records count toward the 128. So 128 records of another machine, which stay for 30 days, stop every reap, and an orphan behind them stays alive.
  • It sends SIGTERM to 64 groups at most. The others keep their records for the next start.
  • Only a regular file is a record. A link, a FIFO or an empty folder with a .json name is removed, with no signal. The target of a link stays. A folder with content stays (from the code).
  • A record that changes between its type test and its open is removed (a folder with content stays), with no signal and no line (from the code).
  • It reads at most 4096 bytes of a record. A record whose first 4096 bytes are not one JSON value is removed, with no signal.
  • If children is not a real folder, it reads, signals and removes nothing. That is measured for a symbolic link to a folder. The other kinds are claustrum's own.

A record of a daemon that is alive stays. So does a record from another machine, for 30 days (from the code). On macOS a daemonStart with two blanks before a one-digit day does not match the live daemon, so a new daemon reads that live daemon as gone. An older claustrum build wrote such a text on days 1 to 9 of a month. That daemon's children then take the test below, and one whose start matches gets SIGTERM. A record of a dead pid is removed. So is a record from an earlier boot of this machine (from the code). For a record of a dead daemon on this machine, the daemon tests the process. If it still is the recorded child, its group gets SIGTERM. Else the record goes with no signal. The test has four parts:

  • The process started at the recorded start, so the pid is not reused. On macOS a start with two blanks before a one-digit day does not match.
  • It leads its own process group.
  • It runs argv0. With a program member, it can also run program, or hold program as one whole argument. On Linux the program is the first argument of /proc/<pid>/cmdline, and a name with the same last path component matches. On macOS the daemon reads the command text of ps, which cuts words at blanks. So a program with a blank never matches an argument there.
  • CLAUDE_SSH_RUN_DIR names this run dir, and CLAUDE_SSH_CHILD names the pid and start of the process itself.

A process that the daemon cannot inspect keeps its record and gets no signal (5fd08069, from the code). The daemon does not test the owner of a record file.

After the SIGTERM the daemon polls for 2 s. At each poll a group takes the whole test again. A group that fails it gets nothing more. A group that still passes after 2 s gets SIGKILL. Then the daemon waits 1 s at most for the group to end (claustrum's own value). After the last group is done, the records of all signalled groups go together. A leader that reads as gone is read again after 50 ms before the SIGKILL of its group (D20). A group that still cannot be inspected at the end, or that outlives the SIGKILL, keeps its record (for the group that outlives it, 4c111e86, measured on Linux). A group that outlives the SIGKILL logs at WARN (claustrum's own level) [process.Registry] WARNING group <pgid> survived SIGKILL; keeping its record for the next start (4c111e86, measured on Linux).

Two risks remain (from the code). A process can change between the last read of /proc or ps and the signal. That window is wider on macOS, where ps runs as its own process. And a remove of a record takes what sits at its name at that time, by one plain remove, never as a tree.

The host settings file (Linux, build 13047a51)

On Linux the daemon reads /etc/claude-desktop-ssh/settings.json at its start. Its member unattendedLimitMinutes sets the unattended limit in minutes, shown by server.capabilities. macOS and Windows read no file (measured on macOS and Windows). The rules below are measured on Linux:

  • No folder /etc/claude-desktop-ssh, or no unattendedLimitMinutes, sets no limit. A link is followed, and a leading UTF-8 byte order mark passes.
  • A value below 15 counts as 15, and a value above 43200 as 43200.
  • A value that is no whole number of 1 or more makes the file unusable. So does a body that is not one JSON object.
  • A size above 64 KiB, a folder and an open refused for its permission make it unusable too.
  • A file of the daemon account makes it unusable. A root file passes.
  • Modes 0664, 0666 and 0646 on the file and 0775, 0777, 0757 and 0753 on its folder make it unusable. Modes 0604 and 0644 and a folder of 0755 pass.
  • The write bits come before the read access. A root file of mode 0642 gets the writable fault.
  • An unknown key sets nothing. A line that sets a limit counts the unknown keys of the top object and names the first.

A file that cannot be used sets no limit, and a Claude Code spawn gets the host_settings refusal. Claustrum's own, not measured: a folder with no file sets no limit, and a FIFO counts as a folder does. A file of another account passes. Any group or other write bit counts. The rules test the target of a link, and only the folder of the file, with no owner test. The first unknown key is the first in the file. The unknown-key tail comes after the clamp tail, and the no-limit line gets it too. Another read error sets no limit and logs one WARN line. A read again after the start is not built.

The start line follows the open-files line and comes before the banner. It is one of these:

[Server] No unattended limit is set in /etc/claude-desktop-ssh/settings.json
[Server] /etc/claude-desktop-ssh/settings.json sets an unattended limit of 60 minutes: once nobody has been connected for that long, this helper ends itself and what it started
[Server] /etc/claude-desktop-ssh/settings.json sets an unattended limit of 15 minutes: once nobody has been connected for that long, this helper ends itself and what it started; unattendedLimitMinutes is 1, which counts as 15 (the bounds are 15 and 43200)
[Server] /etc/claude-desktop-ssh/settings.json sets an unattended limit of 30 minutes: once nobody has been connected for that long, this helper ends itself and what it started; 2 key(s) are unknown to this version of the helper and ignored, the first of them "other" (a misspelt key sets nothing)
[Server] /etc/claude-desktop-ssh/settings.json can't be used, so no Claude Code is started until it is fixed. <detail> No unattended limit applies meanwhile.

The end at the limit

Measured on Linux against 13047a51:

  • The check runs every 60 s from the start of the daemon. The first check after 15 minutes with no client ends it.
  • The clock also counts from the start. The close of a connection that sent a request with the token starts it again.
  • A wrong token or a dial with no byte does not start it again. A held connection with the token holds the end off.
  • It logs the first line below and [Server] shutdown requested. Then it stops as at server.shutdown, and the socket and daemon.token go.
  • The group of each live child gets a SIGKILL, and the first line counts the live children.
  • A child with stream-json in its args gets SIGTERM first. Its group gets the SIGKILL about 1.5 s later.
  • A bare git with stream-json in its args gets SIGTERM first too. Its group gets the SIGKILL within 0.5 s.
  • Then the left-process sweep runs. Its line comes before the cleanup line.
  • A socket path that is gone, a regular file or a link to the socket of another daemon gets the third line below. Then no sweep runs.
[Server] nobody has used this helper or been connected to it for 15m59s, and the unattended limit in force is 15 minutes (/etc/claude-desktop-ssh/settings.json): shutting down and killing 3 child process(es)
[Server] cleanup: ended 3 more process(es) that the children had started and left
[Server] socket path <run dir>/rpc.sock can't be shown to lead to this helper any more, so only its children's own process groups are ended: what has left one may still be running

The third line comes right after the first (measured on Linux). A failed stat of the socket path counts as such a path, and no self-probe runs (claustrum's own, not measured).

For a ccd-cli or launcher spawn, 13047a51 sent that group SIGKILL a second time in some runs. Claustrum on Linux sends a second one after the exit of the leader (killAfterSweepKill, claustrum's own, not measured at the limit end).

Claustrum's own, not measured: a dial of the daemon to itself does not start the clock again. The check comes before the idle exit and the orphan checks, and not once the shutdown began. With -keep-children the children stay and no sweep runs. A failed sweep logs a WARN line of its own.

The left-process sweep (13047a51, Linux)

internal/leftsweep ends the processes that the children of a daemon started and left. Only the end at the limit calls it. On 13047a51 it ran there (measured on Linux). After server.shutdown and after the orphan end, the log of 13047a51 shows no sweep line.

Measured on 13047a51 on Linux, cases A to I. Each case starts a setsid sleep:

  • A has both marks, CLAUDE_SSH_RUN_DIR=<run dir> and CLAUDE_SSH_DAEMON_CHILD=1. It ends by one pidfd_send_signal SIGKILL.
  • B and C have one mark each. They stay alive.
  • D runs as another user, nobody for the real and the effective uid. It stays alive.
  • E runs in a mount namespace where the run folder path is missing. It ends.
  • F sees another folder at that path, with a children entry. It stays alive.
  • G sees another folder at that path, with no children entry. It ends.
  • H sees an absolute link at that path to the real run folder. It ends.
  • I sees a link at that path to a folder with a children entry. It stays alive.

The strace of 13047a51 shows one pid file descriptor open for each pid from 2 up, and none for pid 1 or the daemon. After the pass that ended A, E and G, a second pass ran. It ended none, and the sweep stopped.

claustrum's own, not measured:

  • The parent of the daemon is passed over.
  • At most 3 passes run, with a pause of 20 ms before each next pass. A pid that took the signal gets no second one and counts once.
  • Each mark must be one whole entry, with the exact run folder.
  • An environment over 8 MiB counts as one with no marks.
  • The sweep sends no signal and returns an error for a relative or unclean run folder or a failed stat of it. The same holds for a /proc whose self is another process.
  • The uid test compares the effective uid. Row D cannot tell the real uid from the effective uid.
  • Any other link or a non-folder at the run path keeps the process alive. The parts above the last name are followed, and an absolute link resolves in the root of the daemon.
  • A failed open of the pid file descriptor sends nothing, also on a kernel with no pidfd.
  • macOS and Windows run no sweep.

Idle-connection close

A -serve daemon closes any accepted connection that goes 5 minutes with no read or write. This matches f6010b97 (measured on Linux). 5fd08069 closes at the same times as claustrum (measured on Linux and macOS). The timeout is fixed: no flag, no configuration key. A watcher of each connection checks at a quarter of the timeout, capped at 30 s. At the timeout it closes the socket and logs [Server] closing connection idle <d> in both directions: <addr>. 89cb6289 logs that text with 5m0s and @ (measured on Linux). Claustrum quotes the address and logs no line for a connection that never showed the token (Lines of connections). The watcher ends with its connection and at shutdown. The close sends no frame, and it never ends the daemon. On Linux and macOS the orphan-exit self-probe retires a daemon with no client.

Daemon log (remote-server.log)

The rules of the file and the peer-check lines are measured against 5fd08069, and the startup lines against f6010b97 and 89cb6289. A rule that names one system was measured on that system, and an unmarked rule on Linux and macOS.

At each start the launcher renames an existing remote-server.log in the socket's directory to remote-server.log.old and creates a fresh one with mode 0600. On Linux and macOS some entries are not renamed (below). The daemonized child writes its stdout and stderr there. claustrum keeps the log at shutdown (from the code), unlike the socket and daemon.token. The name and location are fixed.

claustrum writes a level tag before each line of its logger. The banner and a start error that begins claustrum: have none. The reference writes no tag. CLAUSTRUM_LOG_LEVEL=warn drops the INFO lines.

When the raise of the open-files limit works on Linux and macOS, the first line tells the limit that process.spawn children get. It is the lower of 65536 and the hard limit. On Windows the job line comes second. The ready banner follows, with no timestamp:

2026/07/31 00:17:30 INFO  [daemon] child processes will start with an open-files limit of 65536
Claustrum remote server listening on /run/user/1000/claude/rpc.sock (pid 4711, instance 5f1c0a9e2b7d4c3e8a6f0b1d2c3e4f50)
2026/07/31 00:17:30 INFO  [daemon] host cleaning off: socket path "/run/user/1000/claude/rpc.sock" is not <root>/run/<id>/rpc.sock

A failed raise writes no line (claustrum's own). The name Claustrum is claustrum's own, and the reference prints Claude there.

On Linux and macOS a start with CLAUDE_SSH_LEAVE_GROUPS=1 writes its line after the open-files line, before the banner (87375cc7, measured).

If the daemon cannot remove that variable from its environment, it logs this WARN line (claustrum's own):

[Server] cannot remove CLAUDE_SSH_LEAVE_GROUPS from the daemon environment (<error>): child processes inherit it

A start with CLAUDE_SSH_PEER_CHECK=1 writes one more line before the banner. On Linux it is at INFO level, comes after the open-files line, and names the namespaces of the daemon:

[Server] serving only callers in "user:[4026531837] net:1 pidfd"

On macOS and Windows the line is at WARN level and comes last before the banner, with no reap line between them. Its place beside the lines of a reap is not measured. The text is the one of 4c111e86 (measured on macOS and Windows):

[Server] found no namespaces to compare: cannot tell callers in a sandbox from others, serving all

A Linux kernel that names no namespace gets that line too (claustrum's own, not measured). With no user link, the Linux line names only the net part, as "net:1" (measured on Linux, 4c111e86). If the daemon cannot read its own user link, the Linux line is at WARN level instead (the level is claustrum's own, the text measured on Linux, 4c111e86):

[Server] refusing every caller for now: cannot name this server's own namespaces: readlink /proc/self/ns/user: too many open files in system

Each new caller makes the daemon read its namespaces again until one read works. The first good read that names a namespace logs the serving line (measured on Linux, 4c111e86).

At start on Linux, the daemon logs one of these lines once, before the first connection line (measured on Linux, 683cc6a9). Line one follows the host cleaning off line. After a failed own naming, it waits and comes right after the serving line (measured on Linux, 4c111e86 and c9125eb8). Windows logs line one once after the banner, also with no files.realpath call (measured on Windows, 4c111e86 and c9125eb8). On macOS, 4c111e86 and 87375cc7 log line one once, after the host cleaning off line and before the first connection line (measured on macOS). 87375cc7 logs it up to about 40 ms after the banner, so with a fast login shell [shellenv] Extracted shell PATH comes first in most runs (measured on macOS). On macOS claustrum waits up to 40 ms from the start of the shell read, a bound of its own, so it accepts the first connection up to that much later. A held line does not pause for the shell read. With CLAUDE_SSH_NO_LOGIN_PATH_WARM=1 no read runs and the line does not wait (claustrum's own, not measured). The level tag, and the place and count of line two, are claustrum's own, not measured:

[FilesHandler] files.realpath: using the OS's path for the open handle
[FilesHandler] files.realpath: cannot read /proc/self/fd or mnt_id in /proc/self/fdinfo; falling back to filepath.EvalSymlinks, checked against the opened file; files.read will not return real

The old log entry

On Linux and macOS the launcher judges the entry at the path by Lstat. It never opens the old entry or writes through it. 13047a51 gives the same outcomes (measured on Linux and macOS):

  • Only a regular file with one link goes to .old. Another user's file in an own folder goes there too (measured on macOS).
  • Any other entry is not renamed, and the launcher writes a line on its own stderr, not in the log. Examples are a link, a FIFO, a socket, a folder and a file with a second name.
  • A failed rename writes the same line with the error of the rename. A folder at .old gives rename <path> <path>.old: file exists.
  • One plain remove then deletes the entry at the path, never as a tree. A link target and the other name of a file keep their bytes.
  • An exclusive create makes the fresh log.

A create that finds a new entry tries again, up to 3 tries in all (claustrum's own, not measured).

2026/11/28 04:28:39 INFO  [daemon] the last run's log is not kept as .old: it is no regular file, or has a second name

A failed remove fails the start, and the entry stays. A folder with entries gives directory not empty. Another user's file in a sticky folder gives operation not permitted on Linux and permission denied on macOS. A failed create fails the start with its error.

A failed start prints the refusal as its last stderr line and exits 1. 13047a51 prints the same refusal with its own prefix (measured on Linux and macOS). No daemon, socket, daemon.lock or daemon.token follows it (from the code):

claustrum: open log: remove <path>: directory not empty

On Windows the rename acts on a link itself, so the target keeps its bytes. 87375cc7 and 13047a51 do the same (measured on Windows). An error of the rename is ignored. After a failed create, nothing at the path fails the start with the error of the create (from the code), and a folder with is a directory. A regular file is truncated, keeps its mode and gets the lines. A file link fails the start (D8).

On Windows the rename moves a folder onto a regular .old. A second daemon can start on a live socket. The first daemon holds the log open, so the rename fails and the launcher truncates the log for the second daemon. Each daemon writes at the offset of its own handle, so the first daemon's earlier lines are lost and later ones follow NUL bytes. A log that another process holds with no delete share is truncated too, and .old stays. This is parity (D21 is retired).

Lines of connections

These line rules are claustrum's own unless an item names a build. 89cb6289 and 5fd08069 log the text of the notes.

  • A connection gets the token mark at its first request that passes the token check. server.shutdown passes with no token. A parse error and a refused request set no mark.
  • The label of a peer is its address in %q form, such as "@".
  • [Server] New connection from: <label> comes once, at the first request that sets the mark and before the daemon handles it. The older builds log it at the accept.
  • [Server] Connection closed: <label> comes only for a connection with the mark.
  • A connection with no mark counts on the close counter and logs [Server] Connection number <n> that never showed the token: <label>, only if it sent a byte (measured on Linux, 683cc6a9).
  • The refused request logs [Server] Unauthorized request number <n>: method=<method>, with the method cut to 64 characters and quoted and no id. The older text is Unauthorized request: method=…, id=….
  • The bad line logs [Server] Parse error number <n>: <json error>. The older text has no count.
  • The counters are per daemon, one per kind of line. A count starts at 1 and never resets. The line is logged for the counts 1 to 10 and for each multiple of 1000.
  • A failed accept logs [Server] accept error (retrying): <error>. Each retry comes 100 ms later (claustrum's own). 4c111e86 and c9125eb8 log about 10 such lines a second (measured on Linux).
  • The writeResponse: wrote <n>/<m> bytes, error=<error>, Failed to write response: <error> and scanner error on <label>: <error> lines quote the error, and the shutdown logs none. An unmarked connection logs no writeResponse or scanner error line.
  • After a bad last line and a close, an unmarked connection logs no Failed to write response line (4c111e86, measured on Linux). macOS and Windows are claustrum's own.

Lines of child processes

The levels of these lines are claustrum's own. Unless an item says otherwise, each text is that of 89cb6289, measured on Linux. The group-ended, outlived and dropped-record lines are measured on macOS too.

  • A start (INFO): [process.Manager] Process <id> started, PID=<n>, command=<command> (c9125eb8, measured on Linux, macOS and Windows). With a launcher, via launcher <argv0> follows. A launcher that supplies Claude Code logs [process.Manager] Process <id> started, PID=<n>, via launcher <argv0>, which supplies Claude Code (c9125eb8, measured on Linux). On Linux start lines come after [Server] shutdown requested (4c111e86, measured on Linux).
  • A failed start (ERROR): [process.Manager] Failed to start process <id>: <message>, with the error frame's text
  • An exit (INFO): [process.Manager] Process <id> exited with code <n>, then , terminated by <signal> and, for a daemon kill, , asked to end by this daemon (<label>) (52d82f0a, measured on Linux and macOS for client). On Linux one that the shutdown sweep's SIGTERM ends logs (shutdown), and others log none in most runs, (shutdown) in some, a race (87375cc7 and 13047a51, measured on Linux). Plain ones after a temp-folder end log none on Linux, and on macOS a swept child almost none (4c111e86, measured on each). claustrum's own: (client) for the first after a plain process.kill, always none for the others (killedBy), and Windows keeps the line
  • A bad process.kill farewell (INFO): [process] kill <id>: its farewell is not said: <rule> (same build and systems)
  • A refused process.killAndWait (WARN): [process.Manager] KillAndWait <id>: signal terminated failed: <error>, group kill failed: <error> and still running 7s after SIGKILL (D-state?) (52d82f0a, measured on Linux and macOS)
  • A refused signal (WARN): [signal] refused a signal to pid <n>: a pid below 2 is never a child, from sysproc.KillChildGroup, sysproc.ReapProcessGroup, procinfo.KillGroup and supervisor.SignalProcessGroup. It is also the error of a refused process.kill (claustrum's own, not measured)
  • The drain limit (WARN): [process.Manager] Process <id>: pipe drain grace expired (grandchild holding stdio?); force-closing
  • Temp name dropped (WARN): [process.Manager] the inherited <name>=<value> is not handed on to a child: open <value>/.claude-ssh-<n>: <reason> (683cc6a9, measured on macOS). For a missing folder, open names its nearest existing parent (claustrum's own, not measured).
  • A slow temp folder (WARN): [process.Manager] the temporary folder <value> has not answered in 2s: children keep it until it does, once (4c111e86, measured on Linux), from the spawn that started the test (claustrum's own)
  • A supersede (INFO): [process.Manager] process <new id> supersedes <old id> for session <key>: died=<bool> escalated=<bool> alreadyExited=<bool> (from the code), after the exit line of the old process
  • children not a folder (ERROR): [process.Registry] <run dir>/children is not a directory; recording nothing, or reaping nothing at a start
  • children unreadable at a start (ERROR): [process.Registry] cannot read <run dir>/children: <error>; reaping nothing (c9125eb8, measured on macOS with mode 000). Other errors and the line on Linux are claustrum's own, not measured
  • No start time (WARN): [process.Manager] cannot read the start time of pid <n> (no /proc and no ps on this platform): a successor daemon will not be able to reap it (be1c1ca5, measured on Linux with a /proc that holds only self/exe). If /proc/self/stat is missing, claustrum logs it (claustrum's own)
  • A record write fails (ERROR): [process.Registry] cannot record child <pid>: <error>
  • A record remove fails (WARN): [process.Registry] cannot remove record of child <pid>: <error>
  • Over 128 records (WARN): [process.Registry] more than 128 records in <run dir>/children; leaving the rest for the next start
  • Over 64 groups (WARN): [process.Registry] <n> more orphaned group(s) recorded in <run dir>/children than the 64 one start ends; leaving those for the next start
  • A record dropped (INFO): [process.Registry] record <pid>.json: pid <pid> is not a child to end (<reason>); dropping the record, signalling nothing
  • A record kept (INFO): [process.Registry] record <pid>.json: pid <pid> cannot be inspected now (<reason>); keeping the record, signalling nothing (5fd08069, measured on Linux)
  • A group ended (INFO): [process.Registry] ending orphaned process group <pgid> recorded by daemon instance "<instance>" (pid <daemon pid>): SIGTERM
  • The grace ran out (WARN): [process.Registry] group <pgid> outlived SIGTERM for 2s: SIGKILL
  • A group fails the test (INFO): [process.Registry] group <pgid> no longer verifies (<reason>); nothing more is sent to it
  • The reap summary (INFO): [daemon] serve: predecessor's children — <n> orphaned group(s): <a> ended on SIGTERM, <b> on SIGKILL, <c> survived; <d> stale record(s) dropped, <e> kept

A reap that sent no SIGTERM and kept no record writes no summary.

The main <reason> texts of a dropped record and a failed group test are these:

  • it does not run the recorded program "<argv0>", with and neither runs nor was handed "<program>" after it for a record with program
  • it does not lead its own process group
  • it did not start at the recorded "<start>": the pid has been reused
  • it was not started by a daemon of this run dir: no CLAUDE_SSH_RUN_DIR names it
  • it belongs to a daemon of another run dir: its CLAUDE_SSH_RUN_DIR names a different one
  • it was not started by a daemon itself: its CLAUDE_SSH_CHILD does not name its own pid and start (something a child started)
  • environment unreadable: <error>, and on 5fd08069 pid namespace unreadable: <error> and stat unreadable: <error>
  • the record names no program to verify against
  • claustrum's own: pid is out of range, pid is this daemon, pid is this daemon's parent or process group and record has no start time to verify against

A long id in a line

The start, failed-start, exit and Starting <stream> streaming lines cut an <id> over 8 bytes to its first 8 bytes and …. c9125eb8 and 4c111e86 do so, measured on Linux, macOS and Windows. The unattended end line cuts it too (c9125eb8 and 4c111e86, measured on Linux). So does the line of a lost temp folder (4c111e86, measured on Linux and macOS). claustrum's own, not measured: an id with a byte above 0x7f. Every other line shows the whole <id>, also a launcher start line (claustrum's own). The arm and end lines of the top-level unattended end cut it too (claustrum's own).

Orphan-exit self-probe

On Linux and macOS a -serve daemon whose socket path no longer leads back to it shuts down, as on 4534d86. The probe is off the JSON-RPC wire. Its effects are log lines and, once orphaned, a self-directed authed server.capabilities request.

Every 60 seconds the daemon compares its socket path's file identity (os.SameFile) to the inode it bound. The check interval of the reference is not measured. If the path is gone or another inode, a 10-minute grace clock starts. A path that still matches resets the clock. A check that sees a client starts the clock again and writes no line. So the first line below does not come after that client leaves, as on 5fd08069 (measured on Linux and macOS). After the grace with nobody connected, the daemon dials its socket (except at a long socket path, see below) and compares the instanceId of the reply to its own. A probe that reaches itself resets the clock. Two failed probes, 60 seconds apart, start a graceful shutdown. It closes listeners, drops clients, and stops child process groups unless -keep-children is set. 89cb6289 and claustrum exit with code 0, with no signal from another process (measured on Linux). 89cb6289 removes daemon.token (measured on Linux). claustrum removes it through its graceful stop (from the code).

These are the log lines of 89cb6289 in one run, and claustrum logs the same texts with its own values (measured on Linux):

[Server] socket path <socket> no longer leads to this daemon; shutting down if that holds for 10m0s with nobody connected
[Server] socket path <socket> did not lead back to this daemon (1/2); re-checking before acting
[Server] orphaned for 11m0s (socket path gone or re-bound, 2 self-probes failed, no connections); shutting down and killing 0 child process(es)
[Server] shutdown requested
[Server] cleanup: closed 0 connection(s), killed 0 child process group(s)

Since b3081b51 the cleanup: line says ended in place of killed (Log lines).

On 89cb6289 the second line came about 10 minutes after the first, and the third one minute later (measured on Linux). The reference logs orphaned for 11m0s or 12m0s (measured on Linux). claustrum logged 12m0s (measured on Linux), and the code prints 11m0s at exact ticks. The cause of that minute is not measured. At the self-exit 89cb6289 ends the children with SIGKILL, and claustrum ends them too (measured on Linux).

Take a long socket path on Linux with a plain file of the bound mtime at it. be1c1ca5 ends there after 11m0s with its children (measured on Linux). claustrum's probe dials through /proc there. On macOS be1c1ca5 cannot dial such a path. A file with the bound mtime gives this line, and the daemon and its children stay (measured on macOS):

[Server] socket path <socket> is too long for this daemon to dial, but its file is unmodified since this daemon bound it; not orphaned

Another mtime counts as a failed probe (measured on macOS). claustrum's own, not measured: a gone file counts as one too, the grace starts again after the line, and Linux with no usable /proc follows the macOS rule.

A check with no client also ends a daemon after 30 days with no counted request, on the monotonic clock. Each request past auth counts, except server.capabilities. This idle exit is not measured on a reference build.

The checks run on Linux and macOS only. On Windows a daemon whose socket file was deleted writes no line. 5fd08069 wrote no line and was still alive after 14 minutes (measured on Windows).