def signalHandler(self, signum, frame):
        """Meta signal handler that dispatches to registered handlers."""
        signame = Daemon.get_signal_name(signum)
        zLOG.LOG('Z2', zLOG.INFO , "Caught signal %s" % signame)

        for handler in self.registry.get(signum, []):
            # Never let a bad handler prevent the standard signal
            # handlers from running.
            try: handler()
            except SystemExit:
                # if we trap SystemExit, we can't restart
                raise
            except:
                zLOG.LOG('Z2', zLOG.WARNING,
                         'A handler for %s failed!' % signame,
                         error=sys.exc_info())
 def registerHandler(self, signum, handler):
     """Register a handler function that will be called when the process
        recieves the signal signum. The signum argument must be a signal
        constant such as SIGTERM. The handler argument must be a function
        or method that takes no arguments. Note that handlers will not
        be called on non-posix platforms."""
     if os.name != 'posix':
         return
     items = self.registry.get(signum)
     if items is None:
         items = self.registry[signum] = []
         signal.signal(signum, self.signalHandler)
         signame = Daemon.get_signal_name(signum)
         zLOG.LOG('Z2', zLOG.BLATHER, "Installed sighandler for %s" % (
                   signame
                   ))
     items.insert(0, handler)