

Gracefully exiting from console programs in Ruby - marcinbunsch
http://futuresimple.github.com/posts/2012-02-24-graceful-exiting-from-console-programs-in-ruby/

======
tomku
This looks like a cool technique, but what happens if the process gets stuck
in a loop somewhere (maybe in third-party code, or waiting on I/O) where you
can't put calls to the check method in? Maybe it'd be a good idea to check to
see if the flag is already set in the handler, and immediately exit in that
case. That way, hitting ctrl-C once would cause a graceful shutdown, while
hitting it twice (which is a pretty typical reaction if the first doesn't
cause a quick exit) would force-quit in emergencies.

~~~
marcinbunsch
Great point - something like this?

<https://gist.github.com/2038115>

