Fix rare race in pipe-to-command close() result test #213
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.
Here a fix for the test race condition in #206 and the test fail for Linux:
https://github.com/benhoyt/goawk/actions/runs/6293036690/job/17083040381.
I was able to reproduce on my older Macbook and Go 1.17 using
go test -count 1000 -run='TestInterp/^BEGIN { cmd'
... but not consistently. In my case the other pipe-to-command test failed (the one which uses/bin/kill
) but with the same pipe error.Analysis/commit message follows:
The bufio.Writer does not write to the Cmd pipe until Flush is called when the Cmd is Wait-ed on. This causes a Flush error but not a Wait error. This only happens if the Cmd starts and exits before the Flush can be called by goawk.