fix(coding-agent): reclaim reused Termux lease pids - #910
Open
chai1any wants to merge 1 commit into
Open
Conversation
When kill(pid, 0) returns EPERM on Linux or Android, use procfs to distinguish an existing owner from a missing stale or reused PID. Keep conservative behavior for inaccessible proc entries and non-procfs platforms.\n\nFixes PrimeIntellect-ai#868
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
kill(pid, 0)EPERMhandling on Linux and Android with a/proc/<pid>/statprobeOn Termux, a dead worker PID can be reused by a SELinux-protected process. The signal probe then returns
EPERMwhile the proc entry is hidden asENOENT; previously both conditions were treated as proof that the original lease owner was still alive.Verification
npx tsx ../../node_modules/vitest/dist/cli.js --run test/session-lease.test.ts(13 tests passed)npm run checkFixes #868
Note
Fix stale session lease detection for reused PIDs on Android/Termux
On Linux/Android,
isProcessAlivepreviously treatedEPERMfromprocess.kill(pid, 0)as alive, which caused stale leases to become permanent when a dead worker's PID was reused by a protected process.isProcessAliveinsession-lease.tsnow falls back to reading/proc/<pid>/statwhenEPERMis received on Linux/Android;ENOENTin procfs means the process is dead.EPERMcontinues to be treated as alive.ProcessProbedependencies for testing.EPERMon Linux/Android are now considered dead if they have no/procentry, changing the previous unconditional alive result.Macroscope summarized c30502b.