/usr/lib/python2.7/dist-packages/ptrace/signames.py is in python-ptrace 0.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | """
Name of process signals.
SIGNAMES contains a dictionary mapping a signal number to it's name. But you
should better use signalName() instead of SIGNAMES since it returns a string
even if the signal is unknown.
"""
PREFERRED_NAMES = ("SIGABRT", "SIGHUP", "SIGCHLD", "SIGPOLL")
def getSignalNames():
"""
Create signal names dictionay (eg. 9 => 'SIGKILL') using dir(signal).
If multiple signal names have the same number, use the first matching name
in PREFERRED_NAME to select preferred name (eg. SIGIOT=SIGABRT=17).
"""
import signal
allnames = {}
for name in dir(signal):
if not name.startswith("SIG"):
continue
signum = getattr(signal,name)
try:
allnames[signum].append(name)
except KeyError:
allnames[signum] = [name]
signames = {}
for signum, names in allnames.items():
if not signum:
# Skip signal 0
continue
name = None
for preferred in PREFERRED_NAMES:
if preferred in names:
name = preferred
break
if not name:
name = names[0]
signames[signum] = name
return signames
SIGNAMES = getSignalNames()
def signalName(signum):
"""
Get the name of a signal
>>> from signal import SIGINT
>>> signalName(SIGINT)
'SIGINT'
>>> signalName(404)
'signal<404>'
"""
try:
return SIGNAMES[signum]
except KeyError:
return "signal<%s>" % signum
|