olvrlrnz / exec_process

exec_process
GNU General Public License v2.0
3 stars 0 forks source link

timed_read and timed_write do not handle EAGAIN #1

Open bdrewery opened 10 years ago

bdrewery commented 10 years ago

Due to marking the socket nonblocking EAGAIN should probably be checked.

Linux's man 7 pipe documents this:

   O_NONBLOCK enabled, n <= PIPE_BUF
          If there is room to write n bytes to the pipe, then write(2) succeeds immediately, writing all n bytes; otherwise write(2) fails, with errno set to EAGAIN.

Linux has a PIPE_BUF of 4096 while FreeBSD only has 512 bytes. So it is more likely to block on FreeBSD and other systems with small PIPE_BUFs.

This is also discussed here (about select(2)->write(2)) https://stackoverflow.com/questions/13539066/can-write-to-a-non-blocking-fd-return-eagain-when-select-reports-it-as-writabl

olvrlrnz commented 10 years ago

I've added some code to deal with EAGAIN. It would be very nice if you could review it.