mirror of
https://github.com/apple/swift-nio
synced 2026-11-24 04:37:54 +00:00
This PR addresses **#3613** where writing to `/dev/stdout` fails with `ENXIO (6) Device not configured` when running in a terminal environment instead of a pipe. Currently, `SystemFileHandle` checks for `errno == .illegalSeek` (ESPIPE) when deciding whether to fall back from positional `pwrite`/`pread` to non-positional `write`/`read` for unseekable files like pipes. However, macOS/Darwin returns `ENXIO` (`Errno.noSuchDeviceOrAddress`) instead of `ESPIPE` when attempting a positional write/read on a terminal device. **Changes:** - Added `.noSuchDeviceOrAddress` to the fallback conditions in `SystemFileHandle.swift` for both `readChunk` and `write`. - Updated `FileSystemError+Syscall.swift` to map `.noSuchDeviceOrAddress` to `.unsupported` alongside `.illegalSeek`. - Replicated these changes across both the `_NIOFileSystem` and `NIOFS` modules. This allows `FileSystem.shared.withFileHandle` and other APIs to work transparently with terminal devices like `/dev/stdout`!