Signal.action("INT") do |thr|
thr = Thread.main
if thr.alive?
thr.raise Interrupt, "Thread has been interrupted"
else
# If the thread is not alive here, then even the main thread is dead
puts "Signal received, but the main thread is dead."
puts "Unable to continue."
exit! 1
end
end
|
Pastie
