From: Michael Campbell Date: 2003-06-24T06:11:15+09:00 Subject: timeout and gets on windows, or user error? I'm sure this is my misunderstanding, and/or possibly a known thing, but when I put a 'gets' inside a timeout block, it blocks forever. Is this a known windows issue? (XP, if that matters) Here's test code that does what I expect: =============== require 'timeout.rb' $stdout.sync = true begin timeout(5) { 1.upto(10) { |x| puts x sleep 1 } } rescue TimeoutError puts "too much time taken" exit 1 end ================================== It spits out 1 to 5, then the too much time taken. Fine. When I use THIS however... ==================================== require 'timeout.rb' ans = "" $stdout.sync = true begin timeout(5) { print "enter name:" ans = gets.chomp } rescue TimeoutError puts "too much time taken" exit 1 end puts "name is #{ans}" ================================== it sits at the prompt forever. (Interestingly, if i enter a name and wait past the timeout period, I DO get the error printed, but I'm forced to actually enter something. Even MORE interestingly, if I enter NOTHING and wait, but just hit return (after the timeout), I get no error.) Pointers? Thanks, Mike __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com