tests: 🐛 arm the fake CLI's TERM trap before it publishes its pid - #7
Merged
Merged
Conversation
Context: cancelling_run_reaps_the_child_with_sigterm failed intermittently in CI, timing out after 10s waiting for the child to record that it was signalled. Summary: the fake claude CLI installs its TERM trap before writing its pid. Motivation: the pid is what the test waits on before calling abort, so the two lines bracket the exact window in which the test signals. A TERM landing there took the shell's default action, so the child died without writing the term file and the wait loop spun to its timeout. The test was reporting a race in its own fixture, not in the reaping under test. Details: reordering is the whole fix; nothing else observes the pid before the trap matters. Widening the gap with a sleep reproduces the failure against the old order and never against the new one. Claude-Session: https://claude.ai/code/session_015yr73szXYEmbjtNVLxnetK
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.
cancelling_run_reaps_the_child_with_sigtermfailed intermittently in CI, timing out after 10s waiting for the child to record that it had been signalled.The race is in the fixture, not in the reaping under test. The fake
claudeCLI ran these in this order:recorded_pidreturns the instant the pid file parses, and the test callstask.abort()immediately after — so those two lines bracket exactly the window in which the TERM is delivered. A signal landing there takes the shell's default TERM action: the child dies without writing the term file,process_existsgoes false, and the wait loop spins until its 10s timeout.Arming the trap first closes it. Nothing observes the pid before the trap needs to exist, so the reorder is the whole fix.
Reproduced by widening the gap with a
sleepbetween the two lines:termtermtermcargo test -p spawnllm --test integration: 29 passed, 0 failed.https://claude.ai/code/session_015yr73szXYEmbjtNVLxnetK