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
merged 3 commits into from May 21, 2018

Conversation

Projects
None yet
6 participants
@kjbracey-arm
Contributor

kjbracey-arm commented May 2, 2018

Description

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
properly.

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

0xc0170 approved these changes May 4, 2018

@cmonr

This comment has been minimized.

Contributor

cmonr commented May 7, 2018

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

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented May 8, 2018

Build : SUCCESS

Build number : 1940
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6791/

Triggering tests

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

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented May 8, 2018

/morph export-build

@mbed-ci

This comment has been minimized.

@geky

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