From: Paul Brannan Date: 2008-03-14T22:32:33+09:00 Subject: Re: Thread#raise, Thread#kill, and timeout.rb are unsafe On Fri, Mar 14, 2008 at 07:43:28AM +0900, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Thread#raise, Thread#kill, and timeout.rb are unsafe" > on Fri, 14 Mar 2008 06:00:54 +0900, Paul Brannan writes: > > |I'm not convinced KeyboardInterrupt can be handled safely, either, in a > |script. What happens if a KeyboardInterrupt exception is raised inside > |an ensure block? It could easily result in resource leaks. > > You are right, but keyboard interrupt has been there so long in the > history, and we hardly see such leak problems, so I assume it's safer > than you might think. At least, we cannot not removed the interrupts > from the language. For simple scripts, KeyboardInterrupt is probably the right behavior. For applications that use an event loop, we can use trap('INT') to disable KeyboardInterrupt. I wonder if there should be an equivalent trap mechanism for other asynchronous exceptions? Paul