signal handlers need to be deactivated by gipc
This example script:
import gevent.monkey gevent.monkey.patch_all() import gevent from gipc import start_process import os import signal import time def child_handler(): print "Child handler called in PID %d." % os.getpid() def parent_handler(): print "Parent handler called in PID %d." % os.getpid() print "Parent is PID %d." % os.getpid() signal_obj = gevent.signal(signal.SIGTERM, parent_handler) def child(): print "Child is PID %d." % os.getpid() gevent.signal(signal.SIGTERM, child_handler) time.sleep(2) proc = start_process(child) time.sleep(1) os.kill(proc.pid, signal.SIGTERM) proc.join()
Generates output that proves that both signal handlers, the one added in the parent and the one added in the child, are called when the child is sent a SIGTERM signal.
I'd venture to say this is not what is intended.
Note that you can't call signal_obj.cancel() in child(); if you do that the child process will crash.
I think gipc's start process needs to find and cancel all signal handlers right after the fork, before replacing the gevent hub and libevent loop.
In my code, what I'm doing now to work around this is using gc.get_objects() to find all objects that are instances of gevent.hub.signal, and setting object.watcher.callback to a no-op function.