Report abuse


			
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