PROJET AUTOBLOG


shaarli-Links

Site original : shaarli-Links

⇐ retour index

control - How do I capture SIGINT in Python? - Stack Overflow

dimanche 28 août 2016 à 13:11
#!/usr/bin/env python
import signal
import sys
def signal_handler(signal, frame):
    print('You pressed Ctrl+C!')
   sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
print('Press Ctrl+C')
signal.pause()
(Permalink)