Repository navigation
Track programs given a shared >> handle by process handle, not id - #21
Merged
Merged
Conversation
AppendFile kept the process ids of programs started with a shared >> handle and checked them with pid_alive. If one exited and Windows gave its id to an unrelated process, the entry, and the open file, stayed until that process exited, so rm log could fail for a while. Keep a handle to each process instead and check whether it has exited, as suggested in the review of hex2f#6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
hex2f
reviewed
Nov 6, 2026
hex2f
left a comment
Owner
There was a problem hiding this comment.
Thanks for following up on this. Holding a duplicate of the child's process handle fixes the PID-reuse problem: a handle can't come to mean another process, and holding it keeps the ID from being reused anyway. process_running only needs SYNCHRONIZE, and the Child handle has it.
I merged it onto current main: cargo test passes 70/70, and 066_msys_append_concurrent passed 6 runs out of 6. Together with #10 and #11 it passes 72/72. No new clippy warnings.
Looks good to merge.
hex2f
approved these changes
Nov 6, 2026
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.
A follow-up to the PID reuse note in the review of #6.
AppendFilekept the process ids of the programs started with a shared>>handle and checked them withpid_alive. If one of them exited and Windows gave its id to an unrelated process, the entry, and with it the open file, stayed until that process exited, sorm logcould fail for a while.It now keeps a handle to each such process, a duplicate of the
Child's own (try_clone_to_owned), and drops it onceWaitForSingleObjectsays the process has exited (sys::process_running). A handle can't come to mean another process, and holding it keeps the id from being reused while we track it.pid_alivestays forkill -0.Tests
066_msys_append_concurrent.shcovers the behaviour this keeps: concurrent appends, and removing and recreating the file right after an MSYS program appended to it. It passed 5 runs out of 5.cargo testpasses: unit tests, 70/70 compat scripts andmsys_tmp. No new clippy warnings.