Interrupt
Interrupt类
Parent:SignalException
接收到中断信号时触发,通常是因为用户在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.