Skip to content

Instantly share code, notes, and snippets.

@nitheeshkm
Created March 1, 2021 18:51
Show Gist options
  • Save nitheeshkm/43ab26c303b6ad20452c7036d33d2d02 to your computer and use it in GitHub Desktop.
Save nitheeshkm/43ab26c303b6ad20452c7036d33d2d02 to your computer and use it in GitHub Desktop.
Handle CTRL+C in Python
#!/usr/bin/env python
import signal
import sys
def signal_handler(signal, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment