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 9181373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:17:54+00:00 2026-06-17T18:17:54+00:00

I want to append data often to a file on the local filesystem. I

  • 0

I want to append data often to a file on the local filesystem. I want to do this without blocking for too long, and without making any worker threads. On Linux kernel 2.6.18.

It seems that the POSIX AIO implementation for glibc on Linux makes a userspace threadpool and blocks those threads. Which is cool, but I could just as easily spin off my own special dedicated file blocking thread.

  • http://www.kernel.org/doc/man-pages/online/pages/man7/aio.7.html

And it’s my understanding that the Linux Kernel AIO implementation currently blocks on append. Appending is the only thing I want to do.

  • http://code.google.com/p/kernel/wiki/AIOUserGuide
  • https://groups.google.com/forum/#!msg/linux.kernel/rFOD6mR2n30/13VDXRTmBCgJ

I’m considering opening the file with O_NONBLOCK, and then doing a kind of lazy writing where if it EWOULDBLOCK, then try the write again later. Something like this:

  1. open(pathname, O_CREAT | O_APPEND | O_NONBLOCK);
  2. call write(), check for error EAGAIN | EWOULDBLOCK
  3. if EAGAIN | EWOULDBLOCK, then just save the data to be written and try the write() again later.

Is this a good idea? Is there any actual advantage to this? If I’m the only one with an open file descriptor to that file, and I try a write() and it EWOULDBLOCK, then is it any less likely to EWOULDBLOCK later? Will it ever EWOULDBLOCK? If I write() and it doesn’t EWOULDBLOCK, does that mean write() will return swiftly?

In other words, under exactly what circumstances, if any, will write() to a local file fail with EWOULDBLOCK on Linux 2.6.18?

  • 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-06-17T18:17:55+00:00Added an answer on June 17, 2026 at 6:17 pm

    under … what circumstances … will write() to a local file fail with EWOULDBLOCK

    Perhaps there is no circumstance for a file. The Linux man page for write(2) states that EWOULDBLOCK would only be returned for a file descriptor that refers to a socket.

    EAGAIN or EWOULDBLOCK
    The file descriptor fd refers to a socket and has been marked nonblocking (O_NONBLOCK), and the write would block. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities.

    Apparently this behavior is related to the fact that a socket would employ record locks, whereas a simple file would not.

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

Sidebar

Related Questions

String data=this we want append in that file; byte[] getbyte = data.getBytes(); outputstream.write(getbyte); outputstream.flush();
I am appending new data - $('#posts').append(data); But I want this new data to
I want to append data to selectbox. But, I got this error... Error: $().attr(value,
I want to append some data in a file the java code. My file
I have this jquery code: $.ajax({ url:'ajax/windowshop.php', context:'#windowShop', success:function(data){ $('#windowShop').append(data); } }) I want
I have this in PHP: $data = array(test=>array(abc=>xyz)); I want to append ' data:
This code overwrites the file.... I want my previous data to remain the same..
I am working on a utility. I want to append data at the top
I have a in-line delete button, I want to append more data to the
i want to append unlimited number of HTML elements with data given as comment.

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.