Skip to content

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

Merged
merged 3 commits into from
May 21, 2018
Merged

Add POSIX fcntl flag support #6791

merged 3 commits into from
May 21, 2018

Conversation

kjbracey
Copy link
Contributor

@kjbracey kjbracey 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 14:27
kjbracey added 3 commits May 3, 2018 15:38
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);
@cmonr
Copy link
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
Copy link

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
Copy link

mbed-ci commented May 8, 2018

@mbed-ci
Copy link

mbed-ci commented May 8, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented May 8, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented May 8, 2018

Copy link
Contributor

@geky geky left a 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 👍

@cmonr cmonr merged commit a301db5 into ARMmbed:master May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants