[PATCH] ash: clear NONBLOCK flag from stdin when in foreground

Cathey, Jim jcathey at ciena.com
Thu Aug 18 00:11:26 UTC 2011


>>Same question with writes, then. If I poll() my fd 1 and poll returns
>>writability, do I have the guarantee that write() will not block ?

>Yes, if the OS is not buggy.

And if you have some idea of how much should be writable
without blocking under these conditions.  I.e., at least one
byte is writable at that instant in time, but what about more?
Unspecified, so far as I know.

>The only way
>write can block after select/poll on a correct kernel is if another
>process/thread performs a write on the socket after you call
>select/poll but before you call write.

Which is entirely possible, and which illustrates (again) why
poll() and friends are still a POS design.  If you use AIO instead
you get a definitive answer to when _did_ the write complete, rather
than a heads-up that it _might_ be able to complete if you were
to do it now... oops, I mean now... oops I mean...

With AIO you can actually have I/O operations running in parallel
in a single-threaded program, if you want to, whereas with
poll/select you cannot.  (Dependent upon device drivers and
hardware, in addition to the AIO OS of course.)

-- Jim






More information about the busybox mailing list