Any ideas about why the following code hangs in 1.8
(under WinXP) but works fine in 1.6. (This is a major
simplification of some Ctrl-C handling from a larger
project. I don't just have a thing against cats.)
The run results are below.
Thanks.
(Please let me know if this was more suitable for
ruby_core.)
----- dog.rb -------------------------------------
at_exit {
puts "Dog: at_exit"
trap("SIGINT") {
puts "Dog: killing cat..."
Cat.die
puts "Dog: cat whacked."
}
Cat.run
puts "Dog: cat runs no more."
}
----- cat.rb -------------------------------------
require "dog"
module Cat
def Cat.run
@@done = false
until @@done
puts "Cat: yawn"
sleep(2)
end
puts "Cat: eehhkk."
end
def Cat.die
@@done = true
puts "Cat: eeeiiiiyyyeee!"
end
end
----- results ------------------------------------
\ruby-1.6.8\bin\ruby.exe -v cat.rb
ruby 1.6.8 (2002-12-24) [i586-mswin32]
Dog: at_exit
Cat: yawn
Cat: yawn
[I press Ctrl+c]
Dog: killing cat...
Cat: eeeiiiiyyyeee!
Dog: cat whacked.
Cat: eehhkk.
Dog: cat runs no more.
\ruby-1.8.2\bin\ruby.exe -v cat.rb
ruby 1.8.2 (2004-07-29) [i386-mswin32]
Dog: at_exit
Cat: yawn
Cat: yawn
Cat: yawn
[I press Ctrl+c]
Dog: killing cat...
Cat: eeeiiiiyyyeee!
Dog: cat whacked.
[and here we stay forever.]
···
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail