shim/task: make stdio FIFO copying interruptible on darwin #311
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 508 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.373
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #311"
general
weight: 0.35
ericcurtin
On macOS, Go keeps FIFOs opened with
os.OpenFileoff the runtime poller (golang/go#24164). A goroutine parked inread(2)orwrite(2)on a stdio FIFO then pins an OS thread thatClosecannot interrupt, and macOS can also fail to wake a reader when the last writer closes.ioShutdownalso never closed any FIFO descriptor, so these goroutines survive a forced teardown.This adds
copyStreamsPolled, selected on darwin only. Linux and WindowscopyStreamsare unchanged apart from thestdinStreamWriteCloserinterface moving to the shared file.O_NONBLOCKand wrapped withos.NewFile, which registers it with the poller, soCloseand deadlines interrupt a parkedReadorWrite. Opens never block: the stdin reader is opened before the shim's write reference, and the output writer retriesENXIOuntil the client's reader exists.CloseIOonly after every writer is gone and buffered bytes were forwarded in order. EOF is found byread(2)returning 0, and onceCloseIOwas requested the pump re-arms a short read deadline before every read, so it never depends on the last-writer-close wakeup macOS can lose. The re-arm is always a future deadline: a read on an expired one returns without callingread(2)and would drop buffered bytes.copyStreamsimplementations may return anabortfunction thatioShutdowncalls after its bounded waits to close every FIFO descriptor. An aborted stdin does not send the in-band EOF, so truncated input never looks like a clean end.The new code is compiled everywhere except Windows so Linux CI exercises its logic; only darwin selects it (
startCopy).forwardIOgains aforwardIOWithseam so the tests can drive the realioShutdownagainst either implementation. Tests use real FIFOs and an in-memory stream stand-in, and cover detach/re-attach,CloseIOordering,CloseIObefore the client closes, forced shutdown of a parked stdin reader and of a writer blocked on a full FIFO, and the lost-wakeup and expired-deadline behaviour with a fake reader.Related: containerd/fifo#63 (the
O_RDWRvariant of the same workaround in the fifo library).Testing
Run on Linux only. macOS execution is unverified;
io_copystreams_darwin_test.goand the kqueue behaviour need the macOS CI job (or a Mac).gofmtclean;go vet ./internal/shim/task/...clean for linux, darwin (arm64, amd64) and windows.go test ./internal/shim/task/...and the same with-racepass on Linux;GOOS=darwin go test -ccompiles.-race -count=10.Unverified on macOS, please look at the CI result:
open(2).Behaviour differences on darwin
CloseIO.EPIPE(before, it succeeded into a leaked reader).Not changed (pre-existing, noticed while testing)
CloseIOarrives before any client attaches (blocking open in a helper goroutine).ioShutdownstill cannot release parked copies; theaborthook makes that a small follow-up.AI-assisted (opencode, anthropic/claude-sonnet-5-5, xhigh); reviewed by the submitter's assistant, not yet run on macOS hardware.