Skip to content

fix(core): never treat an unreadable or zombie-with-threads group as gone - #331

Merged
ElbertePlinio merged 5 commits into
mainfrom
fix/324-327-proc-stop-unverified
Oct 12, 2026
Merged

ElbertePlinio merged 5 commits into
mainfrom
fix/324-327-proc-stop-unverified

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

The verified group stop no longer treats an unreadable /proc/<pid>/stat as proof that a process is gone. Only ENOENT and ESRCH mean gone. EPERM, EACCES and unparsable stat lines now give a new unverified outcome, so teardown keeps the state the group may still use. The viewer Chrome stop now uses the same present-member rule as the group stop, so a zombie with live threads, or an unreadable member of a group that still exists, keeps the launch directory and profile.

Closes #324
Closes #327

Requirement Verified by Scenario Result Evidence
#324: an unreadable stat in the stop path is unverified, not gone Automated tests Leader stat EPERM before SIGTERM. Leader gone with unreadable entries, with the group probe alive or ESRCH. EPERM after SIGTERM. EPERM after SIGKILL. Before SIGTERM: unverified with no signal. After SIGTERM: unverified with no SIGKILL. After SIGKILL: unverified instead of terminated. A group whose probe gives ESRCH is still already-dead. packages/core/test/proc.test.ts. The new tests failed on main.
#324: the outcome and how callers handle it Code review of every caller browser/src/session.ts, cli/src/viewer/bridge-daemon.ts, desktop-linux/src/apps.ts, display.ts and session.ts all accept only terminated or already-dead as success New unverified outcome. Every caller already keeps its state on it, so no caller changed. Diff and reviews
#324: the identity check stays the last read before SIGKILL Automated test The leader read just before SIGKILL shows PID reuse or EPERM No SIGKILL. Returns reused or unverified. "does not escalate when the last leader read before SIGKILL is …" fails at d45f80f and passes here
#327: the viewer stop uses the present-member rule Code change and tests remainingViewerProcesses uses the new core readProcessGroupPresence A zombie member with live threads, and an unreadable member of a live group, keep the launch packages/desktop-linux/test/viewer-state.test.ts
#327: the launch directory is kept while a zombie leader has live threads Automated test, real kernel Python fixture whose main thread calls pthread_exit while another thread runs, as leader and as member, for both prune and remove Launch kept. The member case failed on main. The leader case already passed on main through the kill(pid, 0) check, and now guards against regressions. viewer-state.test.ts "keeps the launch while a zombie leader/member still has live threads"
Repo checks Full suite with coverage, tsc, oxlint, build, PickCheck PICKFORGE_REQUIRE_BROWSER=1 vitest run --coverage 3097 passed, 6 skipped. Typecheck, lint and build pass. PickCheck reports no findings. Local run at e706624

QA pass skipped: this changes internal process-teardown logic with no UI or CLI output to drive. Real-kernel zombie tests exercise the viewer path.

API note: @pickforge/lab-core gains the readProcessGroupPresence export and an unverified member of StopProcessGroupOutcome. Both are additive. Core is a workspace package and is not published.

Reviews: Astra (xhigh) found that the after-SIGTERM path reread the leader after its identity check, so PID reuse or EPERM at that moment could still escalate to SIGKILL. Fable (xhigh) flagged the same double read. e706624 restores the order main used, with members scanned first and the leader read last, and adds a regression test. Astra and a fresh Fable reviewer both confirmed the fix. The viewer stop still cannot signal a zombie leader with live threads itself; that is tracked in #329.

A /proc/<pid>/stat read that fails with EPERM or EACCES no longer counts
as a gone process in the verified group stop. Only ENOENT and ESRCH mean
gone. An unreadable leader refuses the stop, or stops escalation after
SIGTERM. Unreadable entries with a group that still answers a signal-0
probe keep the group unverified. The new unverified outcome is not a
success, so callers keep the state the group uses.

Refs #324
…reads

The viewer stop now counts group members with the verified group stop
rule through the new readProcessGroupPresence core export. A zombie
with live threads stays present, and unreadable /proc entries in a group
that still exists keep the launch directory and profile in place.

Refs #327
@ElbertePlinio
ElbertePlinio merged commit 1d384b3 into main Oct 12, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/324-327-proc-stop-unverified branch October 12, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: viewer Chrome stop treats a zombie with live threads as gone core: verified group stop reports a group gone when /proc stat is unreadable

1 participant