Ask system to decide non-blocking IO::FileDescriptor (win32)#15753
Merged
straight-shoota merged 4 commits intocrystal-lang:masterfrom May 9, 2025
Conversation
The current implementation inherits the file type check for UNIX to detect special file types (sockets, pipes/fifos, or character devices) for which we must set O_NONBLOCK vs regular disk files (pointless). From what I understand, Windows is more interested to know if the file handle has been opened with OVERLAPPED support for asynchronous IO (non-blocking) or not (blocking).
ysbaddaden
commented
May 6, 2025
straight-shoota
approved these changes
May 6, 2025
ysbaddaden
added a commit
to ysbaddaden/crystal
that referenced
this pull request
May 6, 2025
IO::FileDescriptor (win32)
9 tasks
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current implementation inherited the file type check for UNIX to detect special file types (sockets, pipes/fifos, or character devices) for which we must set
O_NONBLOCKvs regular disk files (not needed).From what I understand, Windows is more interested about whether the file handle has been opened with
OVERLAPPEDsupport for asynchronous IO (non-blocking) or not (blocking).There isn't an official API that reports if the
FILE_FLAG_OVERLAPPEDattribute has been set for a HANDLE. We can, however, use an obscure NT library (dates from Windows 2000) that somehow leaks the information.