Repository navigation
fix: keep a process's identity valid across exec on macOS - #125
Open
behruznassre wants to merge 1 commit into
Open
behruznassre wants to merge 1 commit into
behruznassre wants to merge 1 commit into
Conversation
On macOS the process identity was `ps -o lstart=,comm=`. A legitimate exec keeps the PID and start time but changes comm, so a CC_PLUGIN_CODEX_CLAUDE_BIN shell wrapper that execs Claude failed validateProcessIdentity while alive, and reapStaleJobs marked the running job failed (sendbird#105). The identity is now the start time alone, which a reused PID cannot share. An identity recorded in the old lstart+comm form still matches on its start time, so a job running while the plugin updates is not reaped. Fixes sendbird#105 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getProcessIdentityrecords the process start time alone (ps -o lstart=), so a legitimateexecno longer invalidates a live process's identityvalidateProcessIdentitystill matches an identity recorded in the oldlstart+commform on its start time, so a job that is running while the plugin updates is not reapedtests/process.test.mjsRoot cause
The macOS identity was
ps -o lstart=,comm=. Anexeckeeps the PID and the start time but changescomm. WithCC_PLUGIN_CODEX_CLAUDE_BINpointing at a shell wrapper that execs Claude,runClaudeTurn()captured the wrapper's identity right after spawn. The identity then stopped matching once the wrapper exec'd, andreapStaleJobs()marked the live job failed.PID-reuse protection is unchanged in kind: a reused PID has a different start time.
commadded nothing a start time does not already rule out, short of a PID reused within the same second (lstarthas one-second resolution). Linux already used the/proc/<pid>/statstart time alone.Validation
main(19e5651):{"before":"… /bin/zsh","after":"… node","alive":true,"identityValidated":false}mainand pass with the fix:still validates a process after it execs another programruns a real/bin/shthat execs node, waiting on output markers rather than sleeps, so it has no timing racematches an identity recorded with comm (v1.5.0 and earlier) on its start timecovers the old formatnpm run check: unit 517 passed, integration 45 passed, Codex E2E 23 passed; lint, typecheck, version-sync and changelog OKgit diff --check: cleanNot verified end to end: a real Claude turn through a wrapper. The fix is in the shared identity function that
runClaudeTurn,reapStaleJobsand cancellation all use.Fixes #105
🤖 Generated with Claude Code