'Register signal handlers for ``SIGHUP`` and ``SIGTERM``.
By using signals, a ``\'killed\'`` event will be raised when the
application is terminated.
If a signal handler already existed, it will be executed first,
before the ``\'killed\'`` event is raised.
:param list signals: A list of signal names to be monitored.
Defaults to ``[\'SIGHUP\', \'SIGTERM\']``.'

def use_signals(self, signals=None):

    if (signals is None):
        signals = [u'SIGHUP', u'SIGTERM']
    existing_handlers = {}
    for sig_name in signals:
        if hasattr(signal, sig_name):
            sig = getattr(signal, sig_name)
            handler = signal.getsignal(sig)
            if handler:
                existing_handlers[sig] = handler
    def handle_kill(signum, frame):
        u"\n                                                Capture    kill    event    and    disconnect    cleanly    after    first\n                                                spawning    the    ``'killed'``    event.\n                                                "
        if ((signum in existing_handlers) and (existing_handlers[signum] != handle_kill)):
            existing_handlers[signum](signum, frame)
        self.event(u'killed', direct=True)
        self.disconnect()
    try:
        for sig_name in signals:
            if hasattr(signal, sig_name):
                sig = getattr(signal, sig_name)
                signal.signal(sig, handle_kill)
        self.__signals_installed = True
    except:
        log.debug((u'Can    not    set    interrupt    signal    handlers.    ' + u'SleekXMPP    is    not    running    from    a    main    thread.'))
