Skip to content

Instantly share code, notes, and snippets.

@mikerr
Created August 30, 2013 12:54
Show Gist options
  • Save mikerr/6389549 to your computer and use it in GitHub Desktop.
Save mikerr/6389549 to your computer and use it in GitHub Desktop.
Python: Capture CTRL+C / SIGINT and exit gracefully
import signal
def handler(signum, frame):
print 'Got CTRL+C'
exit (0)
signal.signal(signal.SIGINT, handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment