From: Tanaka Akira Date: 2004-03-27T21:48:24+09:00 Subject: Re: non blocking read and thread In article , "Ara.T.Howard" writes: >> I recommend sysread instead of IO#read with nonblocking mode. > > can you please elaborate on this? why exactly? Because nonblocking sucks. (1) nonblocking flag on a fd may be set/unset unexpectedly by other process if the fd is shared. (2) many code is unaware about nonblocking. For example: (a) Ruby's thread scheduler doesn't assume fds may be nonblocking. [ruby-talk:66196] (b) stdio is unaware about nonblocking. Especially it is too hard to fix data lost on nonblocking write with stdio. [ruby-talk:93917] Although we can fix Ruby, we cannot fix other programs. Setting nonblocking flag may cause problems on other process because (1). See Emacs/SSH case: http://groups.google.com/groups?th=e4df2fdc1f4f4950 http://sources.redhat.com/ml/bug-glibc/2002-08/threads.html#00041 http://sources.redhat.com/ml/bug-glibc/2002-08/threads.html#00186 and DJB's opininon: http://cr.yp.to/unix/nonblock.html -- Tanaka Akira