From: Francis Cianfrocca Date: 2006-05-21T09:54:30+09:00 Subject: Re: sysread changes behavior in the presence of threads? ------=_Part_178932_8457812.1148172866896 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Ahh, thanks for pointing it out, although it ain't the answer I was hoping for. Interesting that your concern (not having to think about EAGAIN) is opposite from mine- I'm *wanting* to get EAGAIN so I can do something else while waiting for the I/O. Solved my problem by holding my nose and writing an IO#read_nonblocking method in C. On 5/20/06, Bill Kelly wrote: > > From: "Francis Cianfrocca" > > > > What am I missing here? > > > > require 'socket' > > require 'fcntl' > > Thread.new {sleep 100} > > sd =3D TCPsocket.new( "www.cisco.com", 80) > > m =3D sd.fcntl( Fcntl::F_GETFL, 0) > > sd.fcntl( Fcntl::F_SETFL, Fcntl::O_NONBLOCK | m) > > sd.sysread(4096) > > > > This code blocks in the sysread, in effect ignoring the nonblocking mod= e > set > > on the file descriptor. But if you comment out the line that spins the > > thread, the sysread raises Errno::EAGAIN as you'd expect. > > > > Is this a defined behavior or a bug? > > Hi, I learned about this just the other day. See thread > starting here: > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/192008 > > > Regards, > > Bill > > > > ------=_Part_178932_8457812.1148172866896--