Skip to content

Instantly share code, notes, and snippets.

@ravelll
Last active August 29, 2015 14:05
Show Gist options
  • Save ravelll/20f43687f12df09a0a79 to your computer and use it in GitHub Desktop.
Save ravelll/20f43687f12df09a0a79 to your computer and use it in GitHub Desktop.
Perfect Ruby p.113 ( trap SIGINT )
# interrupt_handler.rb
trap :INT do
puts '\nInterrupted!'
exit
end
loop do
sleep 1
end
----
# on Terminal
$ ruby interrupt_handler.rb
# push Ctrl + c
Interrupted!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment