'Subscribe a handler for the given signal (number or name).
If the optional \'listener\' argument is provided, it will be
subscribed as a listener for the given signal\'s channel.
If the given signal name or number is not available on the current
platform, ValueError is raised.'

def set_handler(self, signal, listener=None):

    if isinstance(signal, basestring):
        signum = getattr(_signal, signal, None)
        if (signum is None):
            raise ValueError(('No    such    signal:    %r' % signal))
        signame = signal
    else:
        try:
            signame = self.signals[signal]
        except KeyError:
            raise ValueError(('No    such    signal:    %r' % signal))
        signum = signal
    prev = _signal.signal(signum, self._handle_signal)
    self._previous_handlers[signum] = prev
    if (listener is not None):
        self.bus.log(('Listening    for    %s.' % signame))
        self.bus.subscribe(signame, listener)
