fix: close RDWR fifo while reading on darwin - #63
Open
austinvazquez wants to merge 1 commit into
Open
austinvazquez wants to merge 1 commit into
austinvazquez wants to merge 1 commit into
Conversation
Related to containerd#43 Darwin fifo fds are not poller registered, so Close() cannot interrupt a blocked Read(). Scope the fix to O_RDWR, where it's actually safe: holding our own fd open for both directions guarantees there's always at least one writer, so an O_RDWR fifo never depends on detecting a remote peer's EOF via kqueue in the first place. O_RDONLY/O_WRONLY fifos are untouched, still going through os.OpenFile exactly as before. A plain O_RDONLY reader legitimately needs correct EOF detection when its writer closes. Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
There was a problem hiding this comment.
🟡 Changes recommended
The Darwin regression test is not executed by the Ubuntu-only CI test matrix.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes Darwin O_RDWR FIFO closure so Close() interrupts blocked I/O while preserving existing behavior elsewhere.
Changes:
- Adds Darwin-specific poller registration.
- Routes FIFO opening through platform helpers.
- Adds a close-while-reading regression test.
File summaries
| File | Description |
|---|---|
| open_other.go | Preserves standard opening behavior outside Darwin and Windows. |
| open_darwin.go | Implements the Darwin O_RDWR workaround. |
| fifo.go | Uses the platform-specific opening helper. |
| fifo_nolinux_test.go | Tests closing an O_RDWR FIFO during a blocked read. |
Review details
Suppressed comments (1)
fifo_nolinux_test.go:99
- The test description is grammatically incomplete: “guards against closing ... must unblock” does not clearly state the regression. Rephrase it to describe the failure being prevented.
// TestFifoRDWRCloseWhileReading guards against closing an O_RDWR fifo
// must unblock a concurrent, already-blocked Read. On Darwin, os.OpenFile
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // so without openFifoFile's O_RDWR-specific workaround, Close's underlying | ||
| // file.Close() would never interrupt the blocked read(2) syscall and this | ||
| // will hang instead of failing fast. | ||
| func TestFifoRDWRCloseWhileReading(t *testing.T) { |
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.
Related to #43
Darwin FIFO fds are not poller registered, so Close() cannot interrupt a blocked Read().
Scope the fix to O_RDWR, where it's actually safe: holding our own fd open for both directions guarantees there's always at least one writer, so an O_RDWR fifo never depends on detecting a remote peer's EOF via kqueue in the first place.
O_RDONLY/O_WRONLY fifos are untouched, still going through os.OpenFile exactly as before. A plain O_RDONLY reader legitimately needs correct EOF detection when its writer closes.