On Mar 27, 2:41 am, "Just Another Victim of the Ambient Morality"
<ihates... / hotmail.com> wrote:
>     I'm trying to write a program that will poll some website and that is
> easily terminable.  I have a similar Ruby program on a Linux machine that
> polls my inbox to see if I have mail and, whenever I have new mail, prints
> the \b character.  This is done by putting the polling code in a loop in a
> thread block while the main thread simply waits in a gets method.  This
> allows someone to exit the program simply by typing anything.  However, when
> I try this on Win32, it appears that the Ruby interpreter blocks in the gets
> call and the other thread never gets any execution time.
>     So, there appears to be a great discrepancy between the implementations
> on the two systems.  Is this really the case?  Why is this?  Is this
> necessarily so or can we change this?  Shouldn't we like to change this?
> What do you all think?
>     What follows is some example code.  On my Win32 system, this program
> only counts up to 102.
>     Thank you for looking over this...
>
> puts 'start'
>     Thread.new do
>     count = 0
>     loop do
>         puts count
>         count += 1
>     end
> end
> gets

I've asked about this back in September 2007 at ruby-core mailing
list, no answer. I'm copying my post with details more information:

Hello Ruby Developers.

I've been trying to determine what is wrong with this simple script:

http://pastie.caboo.se/101434

t = Thread.new {
   while true
     puts "printing a line"
     sleep 2
   end
 }

gets
t.exit
puts "exiting"

===

And found that all the IO (stdin) is broken on Windows:
custom build with MinGW (3.4.5 -- mingw special)
custom build with VC8
official build VC6

All behave the same way: just 1 line of "printing a line" gets
actually printed, and the world halt until you hit enter.

I saw a few post dating 2003 about this... and this brakes the
cross-platform nature of most of ruby: works on some platform, don't
work on other.

Since 1.8.6 will stay with us a bit longer, any ideas how to solve it?

Park Heesob posted a patch back then, but it don't work as expected
(this problem didn't get solved).

For the record: 1.9.0 don't show this issue, but YARV is another
different breed.

Thanks in advance for your time.

==

Even it doesn't solve your issue, explain it better.

Still, no answer, no solution :'(

Regards,
--
Luis Lavena