[apycotlib] also try to get a human-readable description of the signal
Sadly the stdlib doesn't expose strsignal, so hack around it with ctypes.
--- a/_apycotlib/__init__.py Fri Oct 18 14:08:10 2013 +0200
+++ b/_apycotlib/__init__.py Tue Dec 17 11:13:04 2013 +0100
@@ -26,6 +26,7 @@
from subprocess import STDOUT, Popen
from tempfile import TemporaryFile
import signal
+import ctypes
from logilab.common.textutils import splitstrip
@@ -39,6 +40,16 @@
SIGNUM_TO_NAME = dict((getattr(signal, name), name) for name in dir(signal)
if name.startswith('SIG') and '_' not in name)
+try:
+ strsignal = ctypes.CDLL(None).strsignal
+ strsignal.restype = ctypes.c_char_p
+except AttributeError:
+ pass
+else:
+ for signum in SIGNUM_TO_NAME:
+ SIGNUM_TO_NAME[signum] += ' (%s)' % strsignal(signum)
+
+
def register(category, klass):
"""register a class"""
REGISTRY[category][klass.id] = klass