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

Laurent Bercot ska-dietlibc at skarnet.org
Wed Aug 17 22:56:09 UTC 2011


>> How can I do nonblocking read from fd 0 without
>> affecting other processes which might share it?
> 
> Assuming no other process will be reading at the same time, you simply
> call poll first (or select, but select requires the fd # to be < 1024)
> to check that it won't block, then call read. select and poll are
> specified to only mark the fd readable if a read would not block.

 Okay.
 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 ?
 Even if fd 1 points to the network ? (I've heard things about a
kernel buffer for outgoing data; if some other process fills up the
kernel buffer between poll() and write(), then write() will block.)

 Doing asynchronous loops without O_NONBLOCK does not feel right.

-- 
 Laurent


More information about the busybox mailing list