Right, I didn't realize before that Python interpreter has its own signal handling routines.
Now I am able to handle signals in Python code, but it still barfs on exit: import time import signal import sys def userBreak(sigNum, execFrame): print "Interrupted,,," sys.exit(sigNum) def terminateRun(sigNum, execFrame): print "SIGTERM received, terminating." sys.exit(sigNum) def test(): time.sleep(1) print "success" time.sleep(90) if __name__ == "__main__": signal.signal(signal.SIGTERM, terminateRun) signal.signal(signal.SIGINT, userBreak) test() The error: ./test success ( pressing Ctrl-C ) Interrupted,,, Exception exceptions.SystemExit: 2 in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection Aborted So the real question is - how to exit cleanly from embedded Python code? -- http://mail.python.org/mailman/listinfo/python-list