Basic need: I have a Python daemon that calls another program through os.system. My desire is to be able to handle the shutdown of the system or SIGTERM correctly so that the called program returns and then exits.
What I already tried: I tried the approach using the signal:
import signal, time def handler(signum = None, frame = None): print 'Signal handler called with signal', signum time.sleep(3)
Using time.sleep does not work, and the second print is never called.
I read a few words about atexit.register (handler) instead of signal.signal (signal.SIGTERM, handler), but nothing gets called when kill.
source share