Skip to content

fix: close RDWR fifo while reading on darwin - #63

Open
austinvazquez wants to merge 1 commit into
containerd:mainfrom
austinvazquez:fix/close-rdwr-fifo-while-reading
Open

austinvazquez wants to merge 1 commit into
containerd:mainfrom
austinvazquez:fix/close-rdwr-fifo-while-reading

Conversation

@austinvazquez

Copy link
Copy Markdown
Member

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.

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>
@austinvazquez
austinvazquez marked this pull request as ready for review September 18, 2026 20:09
@austinvazquez
austinvazquez requested a balanced review from Copilot September 18, 2026 20:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread fifo_nolinux_test.go
// 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) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants