类 Interrupt

当接收到中断信号时引发,通常是因为用户按下了 Control-C(在大多数 posix 平台上)。因此,它是 SignalException 的子类。

begin
  puts "Press ctrl-C when you get bored"
  loop {}
rescue Interrupt => e
  puts "Note: You will typically use Signal.trap instead."
end

产生

Press ctrl-C when you get bored

然后等待直到它被 Control-C 中断,然后打印

Note: You will typically use Signal.trap instead.