From: homer nile Date: 2004-11-02T09:03:54+09:00 Subject: at_exit, trap sigint, and sleep. no good in 1.8, ok in 1.6 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. I've been told on ruby_talk that this works fine on 1.8 on Linux. Thanks. (I apologize if this is not suitable for ruby_core. Since it works differently on Windows and Linux, I decided to take a chance that it would be relevant to the implementation gurus.) ----- 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!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com