does Python actually handle SIGTERM and call sys.exitfunc?
Mail Archiving Daemon
bboard at parc.xerox.com
Wed Apr 19 01:43:08 CEST 2000
I'm looking at the documentation for the signal module in the 1.5.2
Library document, which says:
Python installs a small number of signal handlers by default:
`SIGPIPE' is ignored (so write errors on pipes and sockets can be
reported as ordinary Python exceptions), `SIGINT' is translated
into a `KeyboardInterrupt' exception, and `SIGTERM' is caught so
that necessary cleanup (especially `sys.exitfunc') can be
performed before actually terminating. All of these can be
I can find no evidence that SIGTERM is ever caught anywhere in the
interpreter. Can someone point me to the place where this is done?
Also, when I try the following small program:
import sys, time, signal
def writeit (msg):
sys.stdout.write("exiting (" + msg + ")...\n")
sys.exitfunc = lambda x="foo": writeit(x)
running it thusly:
/tmp 359 % python test.py &
/tmp 360 % kill 11067
/tmp 361 %
 Terminated python test.py
/tmp 361 %
I see no output saying "exiting (foo)...".
This might be a documentation bug.
More information about the Python-list