From: Joe Van Dyk Date: 2005-12-09T05:03:58+09:00 Subject: Re: Detecting control-c? On 12/8/05, William E. Rubin wrote: > How does one detect Control-C? > > I know that it raises an Interrupt, but there are other things that are > also Interrupts (such as Timeout::Error). The documentation at > ruby-doc.org doesn't list any details of class Interrupt, and the > "Programming Ruby" book at ruby-lang.org doesn't even seem to mention > that class Interrupt exists. hump:[]:/home/mz652c% cat signal.rb trap("INT") do puts "got signal INT" end puts "Sup" gets hump:[]:/home/mz652c% ruby signal.rb Sup got signal INT got signal INT got signal INT got signal INT got signal INT pressing ctrl-c generates 'got signal INT'. Had to press ctrl-d to exit the program.