How timeout $stdin.gets?

timeout(1) do
$stdin.gets
end

This program is not stopped until user input enter key.
Help me!!

Which version of ruby did you use? It works for me.

ruby-1.9.2-p180 :003 > Timeout.timeout(1) do
ruby-1.9.2-p180 :004 > line = gets
ruby-1.9.2-p180 :005?> end
Timeout::Error: execution expired
from (irb):4:in gets' from (irb):4:ingets’
from (irb):4:in block in irb_binding' from (irb):3 from /home/jduan/.rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in

-Jingjing

windows7
ruby 1.8.6

So I installed 1.9.2
But… result is the same

C:\Ruby192\bin>ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]

On 10/11/11 20:40, Kyung won Cheon wrote:

windows7
ruby 1.8.6

For your particular use case can you simply refactor it to use select?

ruby-1.8.6-p420 :001 > readable = select([$stdin], [], [], 1)
=> nil

Sam

-----Messaggio originale-----
Da: Sam D. [mailto:[email protected]]
Inviato: gioved 10 novembre 2011 20:11
A: ruby-talk ML
Oggetto: Re: How timeout $stdin.gets ?

On 10/11/11 20:40, Kyung won Cheon wrote:

windows7
ruby 1.8.6

For your particular use case can you simply refactor it to use select?

ruby-1.8.6-p420 :001 > readable = select([$stdin], [], [], 1)
=> nil

Sam


Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Capodanno a Riccione, Pacchetto Relax: Mezza Pensione + bagno turco +
solarium + massaggio. Wifi e parcheggio gratis. 2 giorni euro 199 a
persona
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid979&d)-12