"Kevin McConnell" <kevin_mcconnell / hotmail.com> schrieb im Newsbeitrag
news:10m81t9hldp0s2f / corp.supernews.com...
> Brian Candler wrote:
>
> > IO#read and IO#gets work properly; in other words Ruby wraps the calls
> > appropriately to make sure they never block the interpreter engine.
>
> Not sure if any of you use Windows, but it's probably worth pointing out
> that on Windows IO#gets *does* block all threads.
>
> E.g. if I run the following:
>
>    thread = Thread.new { i=0; while(true); puts i+=1; sleep 1; end }
>    sleep 10
>    str = $stdin.gets
>    sleep 10
>
> It should display the numbers 1 to 10, and then go suspiciously quiet
> until you provide the input to gets.  Once you do that, you'll get the
> numbers 11 to 20.

That's not true for the cygwin build:

17:12:51 [ruby]: uname -a
CYGWIN_NT-5.0 bond 1.5.10(0.116/4/2) 2004-05-25 22:07 i686 unknown unknown
Cygwin
17:12:54 [ruby]: ruby -v
ruby 1.8.1 (2003-12-25) [i386-cygwin]
17:12:58 [ruby]: cat ioblock.rb
   thread = Thread.new { i=0; while(true); puts i+=1; sleep 1; end }
   sleep 10
   print "prompt> "
   print "got: ", $stdin.gets, "\n"
   sleep 10
17:13:01 [ruby]: ruby ioblock.rb
1
2
3
4
5
6
7
8
9
10
prompt> 11
12
13
foo
got: foo

14
15
16
ioblock.rb:5:in `sleep': Interrupt      from ioblock.rb:5

Kind regards

    robert