On Feb 20, 2014, at 8:40 AM, Victor Stinner <[email protected]> wrote:

> Setting the O_NONBLOCK flag on a TTY affects all processes. asyncio
> should not do that, but it means that os.read() or os.write() might
> block!?

This is an aspect in which (almost?) all UNIX-like OSes are fundamentally 
flawed.  Blocking-ness is not an attribute of file descriptors, but rather, of 
file "descriptions", something much less well documented and generally 
understood.

See <http://cr.yp.to/unix/nonblock.html> for a general description.

This is especially bad for TTYs because multiple programs are expected to be 
able to share them.  For example, write(1) might decide to share one with you 
at any time.  This isn't actually really possible, and only works by accident 
most of the time because most TTYs are pointed at a user's face rather than at 
anything automated and are rarely doing anything real with job control.

The only real way to deal with this in a portable way is ... to use threads.  
Sorry :-(.

-glyph

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to