Home  >  Magazine  >  #73 May 2000  >  Python Programming for Beginners  >  Listing 3. Signal Traps
Wednesday, March 29, 2000 | Last Updated 03:42:23 PM


  

Listing 3. Signal Traps

#! /usr/local/bin/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'
while 1:
        continue