Determine the signal from its name.  These forms are supported:

        signal object (needed for python >= 3.5)
        integer signal number
        text signal number
        SIGNAME (signal name in upper case)
        signame (signal name in lower case)
        NAME    (name without 'SIG' in upper case)
        name    (name without 'SIG' in lower case)

    In python 3.5 and above, "signal" is an object, so in addition
    to mapping signal numbers and stringified numbers, this also
    maps signal objects.

def signum(signame):
    """
    Determine the signal from its name.  These forms are supported:

        signal object (needed for python >= 3.5)
        integer signal number
        text signal number
        SIGNAME (signal name in upper case)
        signame (signal name in lower case)
        NAME    (name without 'SIG' in upper case)
        name    (name without 'SIG' in lower case)

    In python 3.5 and above, "signal" is an object, so in addition
    to mapping signal numbers and stringified numbers, this also
    maps signal objects.
"""
    if signum.namemap is None:
        #  First time through, map evrything likely to its signal number
        #
        signum.namemap = {}
        for num, nam in sigmap.items():
            signum.namemap[num] = num
            signum.namemap[int(num)] = num
            signum.namemap[str(num)] = num
            signum.namemap[str(int(num))] = num
            signum.namemap[nam.upper()] = num
            signum.namemap[nam.lower()] = num
            abbr = nam.replace('SIG', '', 1)
            if abbr != nam:
                signum.namemap[abbr.upper()] = num
                signum.namemap[abbr.lower()] = num
    return signum.namemap.get(signame)