Skip to content

Instantly share code, notes, and snippets.

@tombruijn
Last active October 18, 2016 08:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
SignalException rescue example
#!/usr/bin/env ruby
# $ ruby signal.rb
# $ kill -QUIT [pid]
puts "Process pid: #{Process.pid}"
puts "I will exit automatically after 50 seconds."
i = 0
loop do
i += 1
begin
sleep 5
rescue SignalException => e
puts e.inspect
end
exit if i > 10
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment