-
Notifications
You must be signed in to change notification settings - Fork 3k
Add POSIX fcntl flag support #6791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was no way to check current blocking state, so no way to modify and restore status. Also have default FileHandle::set_blocking() used by real files return a correct error code when asked for non-blocking, and success when asked for blocking. These were minor omissions that are required to implement POSIX fcntl properly. fixup! Add `is_blocking()` method to FileHandle
Avoid using `fh` for the integer descriptor numbers, reserving that for the `FileHandle` objects - use `fildes` or `fd`, matching POSIX.
Add the POSIX fcntl call, but only implementing F_SETFL and F_GETFL for O_NONBLOCK, so users can control the blocking flag of streams with only the integer file descriptor. Necessary to portably control the blockingness of the console: int flags = fcntl(STDOUT_FILENO, F_GETFL); fcntl(STDOUT_FILENO, F_SETFL, flags | O_NONBLOCK);
Going to get the build started, but could really use feedback from @geky and @SenRamakri /morph build |
Build : SUCCESSBuild number : 1940 Triggering tests/morph test |
Exporter Build : FAILUREBuild number : 1587 |
Test : SUCCESSBuild number : 1762 |
/morph export-build |
Exporter Build : SUCCESSBuild number : 1591 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I thought I already reviewed this one. It looks good to me 👍
Description
POSIX functions added back in #5571 had one omission -
fcntl
, which could be used to control non-blocking. Add enoughfcntl
to do this manipulation. This may be useful in particular to do non-blocking control trickery onSTDOUT_FILENO
.We could also add a method to convert integer file descriptor to
FileHandle
, but this change is useful to permit portable POSIX code.Pull request type