Skip to content

server.*

Three server.* methods describe the daemon and stop it. server.ping tells a client that the daemon answers. server.capabilities lists the methods and the optional features of this build. server.shutdown stops the daemon. server.adoptEnv has its own page. The surprise: server.shutdown needs no token, and its reply can lose a race with the close of the connection.

An untagged rule on this page matches build 5fd08069, measured on Linux. A rule that names macOS or Windows was measured there too.

Request

None of the three methods reads params. A params of any type, or no params member, gives the same reply (from the code).

{"jsonrpc": "2.0", "id": 1, "method": "server.ping", "auth": "<token>"}

server.ping and server.capabilities need the auth member. See server.shutdown.

server.version does not exist. It answers -32601 Unknown method: server.version, as any unknown method does. The -version flag still prints the version of the daemon.

server.ping

{"pong": true}

The reply is always this result.

server.capabilities

{
  "version": "<id>",
  "methods": ["server.ping", "server.capabilities", "server.shutdown", "…"],
  "instanceId": "<32 hex characters>",
  "startedAt": 1760000000000,
  "features": ["process.stdin.offset", "process.spawn.refuses_given_up_id", "process.spawn.unattended_seconds", "process.spawn.unattended_leaves_group", "process.kill.farewell", "files.extract_tar.execBit", "files.list.includeDotNames", "files.list.junctionsAsDirs", "git.status.baseRepo", "git.info.discovered_root", "git.worktree_create.timeoutMs", "git.worktree_create.existingBranch", "git.worktree_create.verified_config", "git.worktree_create.verify_error_codes", "git.worktree_remove.unpushedGuard", "process.spawn.shellAgentSocket", "process.spawn.failure_reason", "process.spawn.git_read", "server.line_end", "launcher.managed", "launcher.non_string_refused", "launcher.supplies_cli", "process.spawn.env_only_if_sent", "server.peer_check", "server.peer_check.out_of_resources", "server.peer_check.absence_shown", "git.outside_session_folders", "git.worktree_create.unusable_git_refused", "git.worktree_create.not_found_codes", "git.shadow_dir", "git.hooks_null_device", "git.status.own_lfs_store", "files.read.real", "files.mkdir.verified_parent", "git.worktree.external_root", "process.spawn.link_bound", "git.worktree_create.another_account_code", "git.worktree_create.own_lfs_store", "git.worktree_create.lfs_error_codes", "process.spawn.cli_temp_root", "process.spawn.cli_temp_root_end", "launcher.checked_by_handle", "launcher.local_kinds_only", "launcher.in_managed_folder", "server.instance_id", "server.unattended_limit", "launcher.exit_ends_group", "process.cli_exit_ends_group", "process.spawn.host_creds_pipe"],
  "peerCheck": "off"
}

The members come in this order:

Member Meaning
version The version of the daemon.
methods The 24 methods, in the order of Methods. files.realpath is last on every system (683cc6a9). On Windows there is no files.mkdir (c9125eb8, measured) and no files.find (4c111e86, measured), so claustrum lists 22.
instanceId 32 hexadecimal characters, new at each start of the daemon. claustrum makes it from 16 random bytes (claustrum's own). On Linux and macOS the owner record of daemon.lock holds the same value. The banner of the daemon log holds it too (measured on 89cb6289).
startedAt The start time of the daemon in unix milliseconds. claustrum sets it after its start steps and the bind of the socket (from the code).
features The optional extensions that this build supports. See Features.
peerCheck The state of the peer check. See The peer check.
peerCheckBy The parts that the check compares. With "off" or "unavailable" the reply has no such member.
unattendedLimitMinutes The limit of the host settings file, while it sets one (13047a51, measured on Linux). Its place after peerCheckBy is claustrum's own.
endedInstances Ended instances.

A request for server.capabilities does not count as activity for the idle exit of the daemon. Every other request past the auth step counts. The idle exit runs on Linux and macOS only. These three rules are claustrum's own, not measured. See Orphan-exit self-probe.

Ended instances (Linux, build 13047a51)

Measured on Linux: a start reads retired.json in the socket folder once, also with no host settings file. 13047a51 wrote no such file in any row, and claustrum writes none.

  • The file holds an object whose member ended is a list. endedInstances comes after unattendedLimitMinutes and shows its good items, with instanceId, reason, limitMinutes and at.
  • A good item has the reason unattended_limit, a limitMinutes from 15 to 43200 and an at above 0.
  • Its instanceId has 32 lowercase hexadecimal characters. A short, an upper-case and a non-hex id drop an item.
  • At most 8 good items show, and the cap counts good items only. A file with no good item shows no member.
  • No file, a folder, a FIFO, mode 0000 and any link show no member. A link is not opened.
  • A hard link and mode 0400 are read. A file of 65536 bytes is read, and one of 65537 is not.
  • Garbage, an empty file and an object with no ended show none either.

Claustrum's own, not measured: the place after peerCheckBy, the order of the file and the last 8 by place. A negative at and a longer id drop an item. A member of another type drops its item. The open adds O_NOFOLLOW, and the open file gets a kind test. macOS and Windows read no file. The read before the socket exists, the read beside a socket of any path and the exact match of keys are claustrum's own too.

Features

The features array is always present. The example above shows the Linux members in the order of b3081b51, less process.spawn.pty, plus process.spawn.git_read and launcher.supplies_cli of c9125eb8. They follow process.spawn.failure_reason and launcher.non_string_refused on Linux, macOS and Windows. 13047a51 adds process.spawn.env_only_if_sent after launcher.supplies_cli on the three systems (measured). be1c1ca5 adds git.hooks_null_device after git.shadow_dir on Linux, macOS and Windows. b3081b51 adds five names of the example on the three systems, and process.spawn.cli_temp_root on Linux and macOS only. c9125eb8 adds files.mkdir.verified_parent after files.read.real on Linux and macOS only (measured), and the example holds that name too. On Linux and macOS 4c111e86 adds git.worktree_create.own_lfs_store and then git.worktree_create.lfs_error_codes after process.spawn.link_bound (measured). There 13047a51 puts git.worktree_create.another_account_code before git.worktree_create.own_lfs_store (measured). 4c111e86 adds process.spawn.cli_temp_root_end after process.spawn.cli_temp_root on Linux and macOS (measured). On Linux 4c111e86 adds launcher.checked_by_handle and launcher.local_kinds_only before server.instance_id (measured), and 13047a51 adds launcher.in_managed_folder after them (measured on Linux). claustrum lists the three on Linux only. On Linux, macOS and Windows 4c111e86 adds server.peer_check.out_of_resources and server.peer_check.absence_shown after server.peer_check (measured). 4c111e86 adds git.worktree_create.unusable_git_refused after git.outside_session_folders, and process.spawn.refuses_given_up_id after process.stdin.offset, on Linux, macOS and Windows (measured). Windows sends no git.worktree.external_root and no process.spawn.link_bound (683cc6a9), and with jobs on adds process.spawn.job last (52d82f0a). A start test that runs past 5 s or failed lists process.spawn.job_pending or process.spawn.job_unavailable there (4c111e86, measured on Windows). On Linux with a /proc that holds only self, 683cc6a9 drops files.read.real. claustrum drops it after a failed start test, whose exact steps are claustrum's own.

CLAUDE_SSH_MANAGED_LAUNCHER does not change the list (measured on macOS). Windows lists launcher.managed too, although a Windows process.spawn refuses every launcher. The peer check changes only the peerCheck and peerCheckBy members.

Names of 87375cc7 that claustrum lists

87375cc7 adds process.spawn.unattended_seconds after process.spawn.refuses_given_up_id and git.worktree_create.not_found_codes after git.worktree_create.unusable_git_refused on the three systems (measured). On Windows only, it adds files.realpath.how_far after files.read.real (measured). On Linux and macOS it adds launcher.exit_ends_group after server.instance_id (measured). CLAUDE_SSH_LEAVE_GROUPS=1 takes that name out. See The group of an exited launcher.

Names of 13047a51 that claustrum lists

13047a51 adds process.spawn.unattended_leaves_group after process.spawn.unattended_seconds on the three systems (measured), also with CLAUDE_SSH_LEAVE_GROUPS=1 (measured on macOS). See the unattended end.

On Linux only, 13047a51 adds server.unattended_limit after server.instance_id, with or without a usable settings file (measured on Linux, macOS and Windows).

On Linux and macOS 13047a51 adds process.cli_exit_ends_group right after launcher.exit_ends_group (measured). CLAUDE_SSH_LEAVE_GROUPS=1 takes both names out (measured on Linux and macOS). See The group of an exited Claude Code.

On Linux 13047a51 adds process.spawn.host_creds_pipe last, also with CLAUDE_SSH_LEAVE_GROUPS=1 (measured). See The hostCreds member.

The peer check

The peer check lets the daemon refuse a caller that runs in other namespaces, for example a process in a sandbox. Only the variable CLAUDE_SSH_PEER_CHECK=1 in the environment of the daemon turns it on. The value must be exactly 1. Any other value, for example 0, true, on, 01 or the empty value, leaves it off. No variable leaves it off too.

The daemon reads the variable once, at its start, and then removes it from its own environment. On Windows the removal covers any letter case. So no child of the daemon inherits it: no process.spawn child, no git call, no launcher run and no login-shell read (the launcher run and the login-shell read: from the code). A process.spawn request whose env names the variable still gives it to that child. If the removal fails, the daemon logs one WARN line (claustrum's own), and the children inherit the variable.

The peerCheck member:

Value When
"off" The variable is not 1. The daemon serves every caller.
"on" Linux, with the variable at 1. The reply then ends with "peerCheckBy":["network","pidfd"].
"unavailable" macOS and Windows, with the variable at 1. The daemon serves every caller.

On a Linux kernel that lacks a part of the check, claustrum answers "unavailable", "network_only" or "by_pid". It can also answer "on" with another peerCheckBy (claustrum's own, not measured).

With 1 the daemon writes one line at its start (the level is claustrum's own). The texts are in Daemon log.

A refused caller (Linux)

On Linux with the check on, the daemon checks each new connection before it reads from it. It compares the namespaces of the caller with its own. A caller that the check refuses gets one frame, and then the connection closes:

{"jsonrpc":"2.0","id":null,"error":{"code":-32006,"message":"Refused: this server could not confirm that the caller is in its own namespaces","data":{"reason":"other_namespace"}}}
reason When
other_namespace The caller is in other namespaces.
unreadable The daemon cannot read the namespace link of the caller.
out_of_resources A step of the check got ENFILE or ENOMEM. Or a user link of the daemon or the caller is gone, on a system that has user namespaces (4c111e86).
lookup_failed The caller exited before the check, or the daemon got EACCES when it read its own namespaces (4c111e86). There ENFILE and ENOMEM give out_of_resources. claustrum gives every other failure of the lookup this reason too (not measured).

The daemon reads no request from a refused connection. So an unauthenticated server.shutdown on that connection does nothing. A caller that wrote first reads the frame and then a reset. A refused connection gets no New connection log line. Refusals 1 to 10 each log one WARN line (the level is claustrum's own). Later refusals log none:

[Server] refused caller number 1 (other_namespace): "user:[4026532385] net:1 pidfd"; this server's namespaces are "user:[4026531837] net:1 pidfd"

A caller that exited before the check gets no line, but it takes a number: the next refusal logs number 2. If the daemon has too many open files, the line gives lookup_failed and caller <pid>: too many open files. Both are measured on Linux, c9125eb8 and 4c111e86.

A failed poll (Linux)

A failed poll of the caller's pidfd gives poll caller <pid>: and the errno text. A poll that gets EINTR runs again. If every poll gets EINTR, the caller gets no reply in 30 s (measured on Linux, 4c111e86). claustrum retries with no limit (claustrum's own). claustrum's own, not measured: such a poll blocks the accept of new connections until the daemon ends.

Out of resources (Linux)

A line of out_of_resources (measured on Linux, 4c111e86):

[Server] refused caller number 1 (out_of_resources): readlink /proc/4711/ns/user: cannot allocate memory; this server's namespaces are "user:[4026531837] net:1 pidfd"

At each connection the daemon reads its own user link again (4c111e86). If that read fails at the start, the daemon refuses every caller and tries the read again for each one. Its lines then show the namespaces "". claustrum serves again after the first read that works (claustrum's own, not measured).

server.shutdown

{"ok": true}

server.shutdown is not authenticated: a shutdown frame stops the daemon with any auth member or none. The exemption covers auth only. A frame with a missing or wrong jsonrpc version gets -32600 Invalid JSON-RPC version, and the daemon stays up. See Authentication. -stop sends this method with no auth member.

The reply races the close

Once the handler starts the stop, the reply waits until teardown starts, on Windows until the stop starts to close the connections, at most 500 ms (claustrum's own, not measured).

  • If the reply wins, the client reads {"jsonrpc":"2.0","id":<id>,"result":{"ok":true}}, then EOF.
  • If the close wins, the client reads EOF with no bytes.
  • Another idle connection gets EOF with no bytes.

A client must treat EOF after a shutdown request as success. On Linux claustrum replies first far more often than 4c111e86. On macOS both reply first in most runs (measured on macOS). In one round on Windows b3081b51 replied in 0 of 60 plain runs and 17 of 60 after a ping (measured on Windows). With a second idle connection it replied in 2 of 60. If claustrum and b3081b51 both send the reply, the frame bytes are equal.

What the stop does

The stop closes the listener. On Linux and macOS, if the socket file is still the one that the daemon bound, the stop removes it (from the code on macOS). On Windows the close of the listener removes the path, also the socket of a successor. Then the stop closes every connection and ends the children that still run, each with its process group on Linux and macOS.

On Linux and macOS b3081b51 first sends SIGTERM to a child whose args hold stream-json, --input-format=stream-json or --output-format=stream-json, and to that child alone. With a launcher the args of the request decide (the last form and the launcher measured on Linux). Every other running child gets the group SIGKILL at once. A child that stays gets the group SIGKILL 1.5 s after the SIGTERM. So the stop takes up to 1.5 s longer (measured on Linux and macOS). A plain spawn that ends on the SIGTERM gets one group SIGKILL after its exit, so a member with no pipe ends too. 87375cc7 and 13047a51 send it (measured on Linux and macOS). In these rows no exit frame reached the socket. A launcher or a Claude Code gets its group end instead. On Windows its job's kill ends each child at once (b3081b51, measured on Windows), since 4c111e86 after a passed start test. Outside a job only the direct child ends (from the code).

A child in its exit drain

When a process holds the stdout or stderr of a child whose leader has exited, the exit frame waits about 5.0 s. If a shutdown comes in that time, 87375cc7 and 4c111e86 send the group SIGKILL after the reap and before the frame. At the 5 s edge 87375cc7 sends the kill in some runs and not in others, and claustrum sent it in each measured run (Linux). After the frame no signal goes, and the member lives on (measured on Linux and macOS). A stream-json child that ends on its SIGTERM with a member on its pipes gets it within 6 ms of the SIGTERM (87375cc7, measured on Linux). After a refused SIGKILL the stop counts that child as exited and waits no longer (87375cc7, measured on Linux).

Which spawns get it

claustrum follows these rows for a spawn with no launcher, gitRead, link, temp folder, pty, unattended time or group end. A pty spawn gets none from this path (claustrum's own, not measured). A pty child of 87375cc7 with no stream-json arg logged its exit before the shutdown and got no signal (measured on Linux and macOS).

The pipe holder test

For a child that did not end on the shutdown SIGTERM, the test is a pipe holder, in the group or not. So a member on its own stdio ends if a process in another session holds the pipes, and that holder lives on (87375cc7, measured on Linux). A client KILL, to the running leader or inside the drain, and then a shutdown make two group kills (87375cc7, measured on Linux). If the exited leader left its group, claustrum sends none at the reap or in a sweep after the reap. If its exit frame is not out, a stream-json child that the shutdown sent a SIGTERM still gets the SIGKILL at 1.5 s. A refused SIGTERM gets it too. Both rules are claustrum's own, not measured.

If a new group took the number after the reap, it gets the SIGKILL, as on 87375cc7 (measured on Linux). The maintainer accepted that risk. On macOS some rules are claustrum's own, not measured: those for an outside holder, a client KILL, a reused number, a refused SIGKILL and the 5 s edge.

With -keep-children the children keep running (CT-2). The stop removes daemon.token by the rules of Token persistence. The daemon then exits with code 0 (from the code).

Log lines

An untagged rule in this section is measured against 5fd08069 on Linux, unless the rule names another build or a system. The order of the shutdown lines and the signal lines were measured against f6010b97 too.

On server.shutdown the daemon logs these two lines before it closes any connection:

[ServerHandler] server.shutdown received over RPC
[Server] shutdown requested

The cleanup line

If the daemon logs a [Server] Connection closed: <label> line, it comes after the close of its connection. Then the daemon logs:

[Server] cleanup: closed <n> connection(s), ended <n> child process group(s)

The first count includes the connection that sent the request (measured against 5fd08069 on Windows only). The word ended is that of b3081b51, where be1c1ca5 says killed (measured on Linux, macOS and Windows). A running child that refused a client KILL and then its shutdown SIGKILL does not count (87375cc7, measured on Linux). A refused group SIGKILL of an open drain does not count (87375cc7, measured on Linux). A refused sweep SIGKILL of a live leader with no client KILL or sweep SIGTERM first does not count either, and a refused sweep SIGTERM counts. Both rules, and the rule on macOS, are claustrum's own, not measured. On Linux the second count also takes a held launcher group whose kill landed before the shutdown (claustrum's own, not measured). Before it, a stop that sent SIGTERM logs this line (b3081b51, measured on Linux and macOS):

[process.Manager] KillAll: asked <n> Claude Code process(es) to end: <n> exited, <n> had to be killed, after <duration>

A stop by SIGTERM first logs [daemon] received terminated; shutting down (children will be killed). Then it logs [Server] shutdown requested and the cleanup: line. For SIGINT the first line names that signal (measured against 5fd08069 on Linux and macOS). With -keep-children the first line says kept in place of killed, and the cleanup: line says ended 0 child process group(s) (both claustrum's own).

A handler panic in server.shutdown writes no frame (claustrum's own). See Handler panic recovery.

Differences by system

The peer check and Features hold the other differences. The start line with CLAUDE_SSH_PEER_CHECK=1 differs:

INFO. It names the namespaces of the daemon (claustrum's own).

WARN. It says that the system names no namespaces (claustrum's own).

WARN, as on macOS (claustrum's own).

Differences from the reference

-keep-children is claustrum's own flag (CT-2). The peer check follows the reference. claustrum lacks the terminal of 52d82f0a, 683cc6a9, be1c1ca5, b3081b51, c9125eb8, 4c111e86 and the pinned build 87375cc7. So it lists no process.resize, and on Linux and macOS no process.spawn.pty (open items).