Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4581962
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:00:17+00:00 2026-05-21T21:00:17+00:00

How is end of file detected for a file in nonblocking mode?

  • 0

How is end of file detected for a file in nonblocking mode?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:00:18+00:00Added an answer on May 21, 2026 at 9:00 pm

    At least on POSIX (including Linux), the obvious answer is that nonblocking regular files don’t exist. Regular files ALWAYS block, and O_NONBLOCK is silently ignored.

    Similarly, poll()/select() et al. will always tell you that a fd pointing to a regular file is ready for I/O, regardless of whether the data is ready in the page cache or still on disk (mostly relevant for reading).

    EDIT And, since O_NONBLOCK is a no-op for regular files, a read() on a regular file will never set errno to EAGAIN, contrary to what another answer to this question claims.

    EDIT2 References:

    From the POSIX (p)select() specification: “File descriptors associated with regular files shall always select true for ready to read, ready to write, and error conditions.”

    From the POSIX poll() specification: “Regular files shall always poll TRUE for reading and writing.”

    The above suffices to imply that while perhaps not strictly prohibited, non-blocking regular files doesn’t make sense as there would be no way to poll them except busy-waiting.

    Beyond the above, there is at least some circumstantial evidence

    From the POSIX open() specification: The behavior for file descriptors referring to pipes, block special files, and character special files is defined. “Otherwise, the behavior of O_NONBLOCK is unspecified.”

    Some related links:

    http://tinyclouds.org/iocp-links.html

    http://www.remlab.net/op/nonblock.shtml

    http://davmac.org/davpage/linux/async-io.html

    And, even here on stackoverflow:

    Can regular file reading benefited from nonblocking-IO?

    As the answer by R. points out, due to how page caching works, non-blocking for regular files is not very easily defined. E.g. what if by some mechanism you find out that data is ready for reading in the page cache, and then before you read it the kernel decides to kick that page out of cache due to memory pressure? It’s different for things like sockets and pipes, because correctness requires that data is not discarded just like that.

    Also, how would you select/poll for a seekable file descriptor? You’d need some new API that supported specifying which byte range in the file you’re interested in. And the kernel implementation of that API would tie in to the VM system, as it would need to prevent the pages you’re interested in from being kicked out. Which would imply that those pages would count against the process locked pages limit (see ulimit -l) in order to prevent a DOS. And, when would those pages be unlocked? And so on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting an end of file before the left brace was matched while trying
I get an EOFError end of file error. when running PrivatePub.publish_to(/dir/file, Some Text) within
I read file, but in the end of file i get unknown symbols: int
Is there a Subversion host that: lets end-users file bug reports arranges bug reports/customer
I am trying to check while not end of file in c programming. Can
In the following script I get an error: syntax error: unexpected end of file
I am using open/read functions, there's feof for fopen/fread to detect end-of-file, what's the
i have the following code ..i need to loop through end of the file
I have a text file where each line may end with some fixed TAG
I have a JavaScript file which is loaded up at the end of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.