Introduce script to display all signal handlers
authorJeff Quast <contact@jeffquast.com>
Mon, 24 Nov 2014 02:26:26 +0000 (18:26 -0800)
committerJeff Quast <contact@jeffquast.com>
Mon, 24 Nov 2014 02:26:26 +0000 (18:26 -0800)
Having a strange issue that only occurs on teamcity
agents, but not from a local shell.  I suspect it
may have to do with isatty() or the build agent
"launcher" which monitors and restarts the agent
should it disappear.

tools/display-sighandlers.py [new file with mode: 0755]

diff --git a/tools/display-sighandlers.py b/tools/display-sighandlers.py
new file mode 100755 (executable)
index 0000000..98445e9
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# Displays all signals, their values, and their handlers.
+from __future__ import print_function
+import signal
+FMT = '{name:<10} {value:<5} {description}'
+
+# header
+print(FMT.format(name='name', value='value', description='description'))
+print('-' * (33))
+
+for name, value in [(signal_name, getattr(signal, signal_name))
+                    for signal_name in dir(signal)
+                    if signal_name.startswith('SIG')
+                    and not signal_name.startswith('SIG_')]:
+    handler = signal.getsignal(value)
+    description = {
+        signal.SIG_IGN: "ignored(SIG_IGN)",
+        signal.SIG_DFL: "default(SIG_DFL)"
+    }.get(handler, handler)
+    print(FMT.format(name=name, value=value, description=description))