Repository navigation
helper: write the last log line before signalling the caller - #1137
Merged
Merged
Conversation
The caller exits as soon as it gets SIGALRM, and whatever ran it may then remove the log file's directory. Writing bye(0) after the signal could re-create the log file mid-removal, which made the e2e test's cleanup fail intermittently with 'Directory not empty'.
There was a problem hiding this comment.
🟡 Changes recommended
A moderate issue remains in kart/helper.py because the ProcessLookupError path logs after signalling, allowing cleanup to race the write and potentially raise FileNotFoundError.
1 open issue
What changed in this PR
Updates helper shutdown ordering so the final log entry is written before signaling the caller, preventing cleanup from racing with a late log-file write.
Changes:
- Combines the final
bye(0)marker with the pre-signal log entry. - Exits the helper child immediately after the signalling attempt.
| File | Description |
|---|---|
| kart/helper.py | Reorders final helper logging and child termination around SIGALRM to avoid recreating the log file during temporary-directory cleanup. |
Review effort: Lite
Its cleanup may be running too, so the write could still race it.
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.

Description
The
e2e test (helper)step fails intermittently in its cleanup, for example in this run:The e2e script puts
KART_HELPER_LOGinside its temp folder and removes the folder on exit. After running a command, the helper's forked child sentSIGALRMto the caller and then wrotebye(0)to the log. The caller exits onSIGALRM, so the script'srm -rfcould run while that last write re-created the log file. In the failing run, the helper log ends with the last child'ssending SIGALRMline and nobye(0), so the cleanup had already read the log when the child wrote its final line.The child now writes its final log line before signalling, and exits straight after.
Not covered by an automated test, because the window is only a few microseconds: 200 runs of a command through the helper, each followed immediately by removing the log directory, never hit it. With a temporary 50 ms sleep added right after the helper sends
SIGALRM, the same loop gives:The e2e script passes with and without the helper.
Related links:
Checklist:
Claude session ID:
389a86fe-c780-459f-81e3-70b768e03b1b