faqts : Computers : Programming : Languages : Python

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 14 people (79%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I create a 'catch all' way to catch all possible signals?

Aug 29th, 2002 00:14
Peter Funk, Joćo Prado Maia,


On unixoid operating systems (AIX, Linux, SunOS, ...) there is
a special signal called SIGKILL, which can't be catched at all.
With the exception of this you can try the following:
import signal, os
def mysignal_handler(signum, frame):
    print 'Signal handler called with signal', signum
for signum in range(signal.SIGHUP, signal.NSIG-1):
    if signum != signal.SIGKILL:
        signal.signal(signum, mysignal_handler)