Fix run_shell timeouts on Windows#1
Open
quicktoolbox wants to merge 2 commits into
Open
Conversation
The time.AfterFunc timer goroutine (kill) and the deferred main-goroutine cleanup could touch the same job-object handle concurrently — timer.Stop() does not join an in-flight callback. cleanup() could CloseHandle while kill() was mid-TerminateJobObject, and Windows recycles handle values, so a use-after-close could terminate an unrelated job. Add a sync.Mutex to processTree: kill() holds it across TerminateJobObject, cleanup() holds it while closing and zeroing the handle. configureProcessGroup now returns *processTree so the mutex is never copied (copylocks). Also document the grandchild-escape window and the KILL_ON_JOB_CLOSE behavior, and drop dead `_ = err` lines.
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
Verification
go test ./internal/jinn -run 'TestRunShell|TestTokenEfficiency_RunShell'go test ./cmd/jinngo build -o /tmp/jinn-pr-check.exe ./cmd/jinnGOOS=linux GOARCH=amd64 go build -o /tmp/jinn-pr-check-linux ./cmd/jinn{"tool":"run_shell","args":{"command":"printf ok","timeout":5}}