Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
Signal.action("INT") do |thr| # We can't raise on ourselves, we raise on main. if thr == Thread.current or not thr.alive? thr = Thread.main end if thr.alive? # Push the output down a little bit, makes things look more # obvious that the system was interrupted. puts thr.raise Interrupt, "Thread has been interrupted" else # If the thread is not alive here, then even the main thread is dead puts "Signal received, but the main thread is dead." puts "Unable to continue." exit! 1 end end
This paste will be private.
From the Design Piracy series on my blog: