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

Add POSIX fcntl flag support #6791

merged 3 commits into from May 21, 2018


None yet
6 participants

kjbracey-arm commented May 2, 2018


POSIX functions added back in #5571 had one omission - fcntl, which could be used to control non-blocking. Add enough fcntl to do this manipulation. This may be useful in particular to do non-blocking control trickery on STDOUT_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

[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change

@0xc0170 0xc0170 requested review from geky and SenRamakri May 2, 2018

kjbracey-arm added some commits May 2, 2018

Add `is_blocking()` method to FileHandle
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

fixup! Add `is_blocking()` method to FileHandle
retarget: distinguish FileHandle and descriptor
Avoid using `fh` for the integer descriptor numbers, reserving
that for the `FileHandle` objects - use `fildes` or `fd`,
matching POSIX.
Add POSIX fcntl to control blocking
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);

@kjbracey-arm kjbracey-arm force-pushed the kjbracey-arm:fcntl branch from 166a46c to cf91b1c May 3, 2018


0xc0170 approved these changes May 4, 2018


This comment has been minimized.


cmonr commented May 7, 2018

Going to get the build started, but could really use feedback from @geky and @SenRamakri

/morph build


This comment has been minimized.

mbed-ci commented May 8, 2018


Build number : 1940
Build artifacts/logs :

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build


This comment has been minimized.


This comment has been minimized.


This comment has been minimized.


0xc0170 commented May 8, 2018

/morph export-build


This comment has been minimized.


geky approved these changes May 8, 2018

Sorry, I thought I already reviewed this one. It looks good to me 👍

@cmonr cmonr removed the needs: review label May 21, 2018

@cmonr cmonr merged commit a301db5 into ARMmbed:master May 21, 2018

13 checks passed

AWS-CI uVisor Build & Test Success
ci-morph-build build completed
ci-morph-exporter build completed
ci-morph-mbed2-build build completed
ci-morph-test test completed
continuous-integration/jenkins/pr-head This commit looks good
continuous-integration/travis-ci/pr The Travis CI build passed
travis-ci/astyle Passed, 582 warnings (+0 warnings)
travis-ci/docs Local docs testing has passed
travis-ci/events Passed, runtime is 10375 cycles (+175 cycles)
travis-ci/gitattributestest Local gitattributestest testing has passed
travis-ci/littlefs Passed, code size is 10112B (+0.00%)
travis-ci/tools Local tools testing has passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment