Repository navigation
fix(nio-filesystem): Fallback to non-positional read/write on ENXIO (Fixes #3613) - #3671
Conversation
glbrntt
left a comment
There was a problem hiding this comment.
This PR has lots of unrelated changes, can you trim it down to just the ones relevant to this PR?
cf804dc to
2d3c4a9
Compare
|
Thanks @glbrntt! I've trimmed down the branch to contain only the single relevant commit for the ENXIO fallback fix. |
| from the file system. | ||
| """ | ||
| case .illegalSeek: | ||
| case .illegalSeek, .noSuchDeviceOrAddress: |
There was a problem hiding this comment.
There are tests that validate these mappings. Can you update them please?
|
Thanks @glbrntt, I have just updated the |
glbrntt
left a comment
There was a problem hiding this comment.
This doesn't compile on Linux, you'll need to fix that up too.
|
Ah, good catch! I accidentally used |
Hey @weissi! 👋
This PR addresses #3613 where writing to
/dev/stdoutfails withENXIO (6) Device not configuredwhen running in a terminal environment instead of a pipe.Currently,
SystemFileHandlechecks forerrno == .illegalSeek(ESPIPE) when deciding whether to fall back from positionalpwrite/preadto non-positionalwrite/readfor unseekable files like pipes. However, macOS/Darwin returnsENXIO(Errno.noSuchDeviceOrAddress) instead ofESPIPEwhen attempting a positional write/read on a terminal device.Changes:
.noSuchDeviceOrAddressto the fallback conditions inSystemFileHandle.swiftfor bothreadChunkandwrite.FileSystemError+Syscall.swiftto map.noSuchDeviceOrAddressto.unsupportedalongside.illegalSeek._NIOFileSystemandNIOFSmodules.This allows
FileSystem.shared.withFileHandleand other APIs to work transparently with terminal devices like/dev/stdout!