def main():
    uncatchable = ['SIG_DFL', 'SIGSTOP', 'SIGKILL']
for i in [x for x in dir(signal) if x.startswith('SIG')]:
    if not i in uncatchable:
        signum = getattr(signal, i)
signal.signal(signum, receive_signal)
Python - Trap all signals