def trace_signal(pid, flags, tricklist, sig):
    if not _signal_weedout_mask[sig]:
        return sig

    signalname = signalmap.lookup_name(sig)

    # innermost trick gets first shot at the signal
    tricklist = tricklist[:]
    tricklist.reverse()

    for trick, callmask, signalmask in tricklist:
        if (not signalmask or signalmask.has_key(signalname)) and trick.is_enabled(pid):
            r = trick.signal(pid, signalname)
            # r is None or (signal, )
            if r != None:
                assert len(r) == 1, "signal must return None or a 1-tuple"
                signalname = r[0]
                assert isinstance(signalname, types.StringType) and (
                    0 <= signalmap.lookup_number(signalname) < signal.NSIG
                ), ("bad signal %s; must use signal name" % signalname)
                if signalname == "SIG_0":
                    break
                    # XXX: perhaps we ought to also ignore signals that the
                    # process is ignoring ??

    return signalmap.lookup_number(signalname)
Beispiel #2
0
def trace_signal(pid, flags, tricklist, sig):
    if not _signal_weedout_mask[sig]:
        return sig

    signalname = signalmap.lookup_name(sig)

    # innermost trick gets first shot at the signal
    tricklist = tricklist[:]
    tricklist.reverse()

    for trick, callmask, signalmask in tricklist:
        if (not signalmask or signalmask.has_key(signalname))\
                                         and trick.is_enabled(pid):
            r = trick.signal(pid, signalname)
            # r is None or (signal, )
            if r != None:
                assert len(r) == 1, "signal must return None or a 1-tuple"
                signalname = r[0]
                assert (isinstance(signalname, types.StringType)
                 and (0 <= signalmap.lookup_number(signalname)
                      < signal.NSIG)), \
                       "bad signal %s; must use signal name" % signalname
                if signalname == 'SIG_0':
                    break
                # XXX: perhaps we ought to also ignore signals that the
                # process is ignoring ??

    return signalmap.lookup_number(signalname)
Beispiel #3
0
def set_trick_signal_handlers(tricklist):
    sigs = {}
    for tricktuple in tricklist:
        trick = tricktuple[0]
        tricksigs = trick.tricksignalmask()
        if tricksigs:
            for sig in tricksigs.keys():
                sigtricks = sigs.get(sig, [])
                sigs[sig] = sigtricks + [trick]
    for sig, tricks in sigs.items():
        signal.signal(signalmap.lookup_number(sig),
                      lambda s, f, t = tricks: handle_sf_signal(s, f, t))
Beispiel #4
0
def set_trick_signal_handlers(tricklist):
    sigs = {}
    for tricktuple in tricklist:
        trick = tricktuple[0]
        tricksigs = trick.tricksignalmask()
        if tricksigs:
            for sig in tricksigs.keys():
                sigtricks = sigs.get(sig, [])
                sigs[sig] = sigtricks + [trick]
    for sig, tricks in sigs.items():
        signal.signal(signalmap.lookup_number(sig),
                      lambda s, f, t=tricks: handle_sf_signal(s, f, t))