summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJeff Quast <contact@jeffquast.com>2014-11-23 18:26:26 -0800
committerJeff Quast <contact@jeffquast.com>2014-11-23 18:26:26 -0800
commit43f5010d702630a899dc27389fa56238c88875ca (patch)
treedc2abc64448baa59c590c2763822d4dbd99967d3 /tools
parent8cce225840ee22d375f3e6892fc6931f866cf0b8 (diff)
downloadpexpect-git-43f5010d702630a899dc27389fa56238c88875ca.tar.gz
Introduce script to display all signal handlers
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.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/display-sighandlers.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/display-sighandlers.py b/tools/display-sighandlers.py
new file mode 100755
index 0000000..98445e9
--- /dev/null
+++ b/tools/display-sighandlers.py
@@ -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))