Repository navigation
exec: enforce timeout when a child keeps output pipes open - #39
Merged
Merged
Conversation
CommandContext kills only the direct child on timeout; CombinedOutput then kept waiting for the output pipe, which any background grandchild holds, so `sh -c "sleep 20; echo done"` ignored --timeout and `sh -c "daemon &"` never returned. Set WaitDelay so pipes are closed shortly after exit or kill, and treat ErrWaitDelay after a successful exit as success. Fixes #35
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.
Fixes #35.
cmd.WaitDelay = 1s: after the command exits or is killed by the context, output pipes are force-closed within 1s instead of waiting for every grandchild.exec.ErrWaitDelaywith a successful exit status counts as success (command exited 0 but left a background process holding stdout).Tests (both took 10s and failed before, ~1s now):
sleep 10; echo donewith 200ms timeout errors promptly;sleep 10 & echo startedsucceeds promptly.