Skip to content

Centralize I/O error handling and make read/write functions portable#15305

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:file-system-prep
Feb 20, 2026
Merged

Centralize I/O error handling and make read/write functions portable#15305
Ericson2314 merged 1 commit intoNixOS:masterfrom
obsidiansystems:file-system-prep

Conversation

@amaanq
Copy link
Member

@amaanq amaanq commented Feb 20, 2026

Motivation

  • Improve existing read and readOffset wrappers:

    • Unix: Add EINTR retry handling and checkInterrupt
    • Windows: Handle ERROR_BROKEN_PIPE as EOF, add checkInterrupt
  • Add write wrapper with same treatment (EINTR on Unix, checkInterrupt)

  • Improve many windows/file-descriptor.cc error messages with descriptorToPath

  • Move readFull, readLine, writeFull to common file, using the platform wrappers instead of duplicating platform-specific logic. These ones don't need any EINTR or interrupt checking either. They only have EGAIN checking as Unix-specific code, but this is a temp hack to be removed per Remove pollfd workaround #12688, so its fine that it goes in the platform-agnostic file for now.

  • Add retryOnBlock helper to abstract EAGAIN/EWOULDBLOCK poll-and-retry logic (Unix only, needed for buildhook workaround Remove pollfd workaround #12688)

  • Simplify FdSource::readUnbuffered to just call nix::read

  • Remove now-dead EINTR handling from drainFD and copyFdRange

  • writeErr better impl on Windows


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@amaanq amaanq requested a review from edolstra as a code owner February 20, 2026 15:48
@Ericson2314 Ericson2314 force-pushed the file-system-prep branch 3 times, most recently from 5cd8ec1 to 06bbc86 Compare February 20, 2026 15:53
@Ericson2314 Ericson2314 changed the title Centralize read error handling in read and readOffset wrappers Centralize I/O error handling and make read/write functions portable Feb 20, 2026
@Ericson2314 Ericson2314 force-pushed the file-system-prep branch 2 times, most recently from 97c6510 to 7588701 Compare February 20, 2026 16:22
- Improve existing `read` and `readOffset` wrappers:
  - Unix: Add `EINTR` retry handling and `checkInterrupt`
  - Windows: Handle `ERROR_BROKEN_PIPE` as EOF, add `checkInterrupt`

- Add `write` wrapper with same treatment (`EINTR` on Unix, `checkInterrupt`)

- Improve many `windows/file-descriptor.cc` error messages with
  `descriptorToPath`

- Move `readFull`, `readLine`, `writeFull` to common file, using the
  platform wrappers instead of duplicating platform-specific logic.
  These ones don't need any `EINTR` or interrupt checking either. They
  only have `EGAIN` checking as Unix-specific code, but this is a temp
  hack to be removed per NixOS#12688, so its fine that it goes in the
  platform-agnostic file for now.

- Add `retryOnBlock` helper to abstract `EAGAIN`/`EWOULDBLOCK` poll-and-retry
  logic (Unix only, needed for buildhook workaround NixOS#12688)

- Simplify `FdSource::readUnbuffered` to just call `nix::read`

- Remove now-dead `EINTR` handling from `drainFD` and `copyFdRange`

- `writeErr` better impl on Windows
@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 20, 2026
Merged via the queue into NixOS:master with commit b10cb65 Feb 20, 2026
15 checks passed
@Ericson2314 Ericson2314 deleted the file-system-prep branch February 20, 2026 18:19
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