Repository navigation
Description
Problem
is_process_alive (pkgs/id/src/commands/serve.rs:200-206) treats any kill(pid, 0) result other than 0 as "dead":
unsafe { libc::kill(pid as i32, 0) == 0 }kill(pid, 0) also fails with EPERM when the process exists but is owned by another user — existence is exactly what the probe is asking about. On a multi-uid machine (serve started by one uid, a CLI/REPL process run by another — e.g. a user service vs an interactive shell, or a root-started serve inspected by the daily user) the function therefore answers "dead" for a live serve.
The only consumer, get_serve_info (serve.rs:171-185), acts on that answer destructively:
if !is_process_alive(info.pid) {
// Stale lock file - remove it
let _ = afs::remove_file(SERVE_LOCK).await;
return None;
}So a live serve's .iroh-serve.lock is deleted by a process running as a different uid, and discovery reports "no serve running" — every command that consults the lock first falls back instead of connecting to the serve that is actually up.
The codebase already knows the correct rule in the sibling component: mcpx's ProcessAlive (pkgs/mcpx/internal/daemon/paths.go:299-313) documents and implements "EPERM means the process is there but owned by somebody else, which is still alive". The converse bug in mcpx's pool checker is tracked separately as #2336.
This is distinct from #2142 (same function): that issue covers sentinel pids (0 / u32::MAX) being passed to kill and answering "alive" for no process. This issue covers the errno of a legitimate pid never being inspected, answering "dead" for a real process. Either fix alone leaves the other defect in place.
Evidence (verified this run, main 5a34fa70)
serve.rs:200-206: the return value is compared to0only;errnois never read.serve.rs:1873-1880: the existing testtest_is_process_alive_pid_1deliberately asserts nothing ("Just check that the function doesn't panic") — pid 1 is the canonical foreign-owned live pid, and the test cannot asserttruebecause the function gets it wrong for non-root callers.- Probe on the laptop (
~/git/fleet/probe-2026-10-29-laneB-serveeperm/, verbatim function logic via a directkillextern, run as the laptop's non-root daily user):own pid 1582009 -> true pid 1 (alive, root-owned) -> false dead pid 1582067 -> false - OS-level cross-check on the same host:
kill(1, 0)returns errno 1 (EPERM) for the non-root user, while a dead pid returns errno 3 (ESRCH) — the information needed to distinguish the cases is present and is being discarded.
Why it matters
Serve discovery is the front door for most CLI commands in a served directory. Deleting a live serve's lock is worse than misreporting it: the lock does not come back until the serve restarts, so one cross-uid invocation permanently (for that serve's lifetime) breaks discovery for everyone, with no error naming the cause.
Acceptance criteria
-
is_process_alivedistinguishesEPERM(alive) fromESRCH(dead): a live foreign-owned pid returnstrue. -
get_serve_infono longer removes the lock of a live foreign-owned serve; it returns that serve's info. - Ordinary behaviour is unchanged: own live pid →
true, dead pid →false(lock removed as stale). - Regression test:
test_is_process_alive_pid_1(or a successor) asserts pid 1 is alive on Unix when it exists, instead of asserting nothing — or an equivalent EPERM-path test is added. - The fix composes with id(serve): is_process_alive answers 'alive' for pid 0 and u32::MAX — a lock file with either pid is never stale and wedges serve discovery #2142's sentinel-pid guard (whichever lands first, the second rebases onto it rather than re-deciding the other case).
Activity
developing-today commentedon Oct 29, 2026
CODE-1211
dezren39 commentedon Oct 29, 2026
🤖 Agent note · filed
dezren39 commentedon Oct 29, 2026
🤖 Correction (new-issue-creator-code-b): the agent-note footer on the filing note above reads at=2026-10-29T17:42:00Z; the actual filing time was 2026-10-29T17:29:00Z. Timestamp typo only — substance unaffected.
Merge pull request #3420 from developing-today/queue/5262-2384-serve-…
dezren39 commentedon Nov 1, 2026
🤖 Agent note · done
is_process_alivenow treats EPERM as alive (rc==0 or errno==EPERM vialast_os_error), mirroring mcpx ProcessAlive; assert-nothing pid-1 test replaced with an asserting regression test.test_is_process_alive_*3/3 pass, fullcommands::servemodule 15/15 pass. Codex review on 74c1a6e completed with no findings. One unrelated pre-existing failure in the full binary run —cli::tests::test_cli_parse_catstack-overflows even in isolation; the parse path does not callis_process_alive; filed separately as id(cli): test_cli_parse_cat stack-overflows in the pkgs/id test binary (pre-existing, parse path) #3438.21 remaining items
dezren39 commentedon Nov 1, 2026
🤖 Agent note · parked
queue/5262-2384-serve-eperm@74c1a6e75· laptop worktree~/git/fleet/5262Parked because the targeted
cargo test --lib test_is_process_alivecompile on the laptop is still running after ~18 minutes (laptop load ~115 from fleet-wide builds; the dependency tree is most of the cost — the change itself is 12 lines). The PR is open with the full diff; do not re-implement. On resume: the compiled test binary lands in~/git/fleet/target-5262/debug/deps/(or rerun the cargo command in~/git/fleet/5262/pkgs/idwithCARGO_TARGET_DIR=$HOME/git/fleet/target-5262— the target dir is warm).dezren39 commentedon Nov 1, 2026
🤖 Agent note · picked up