OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Displays all signals, their values, and their handlers. |
| 3 from __future__ import print_function |
| 4 import signal |
| 5 FMT = '{name:<10} {value:<5} {description}' |
| 6 |
| 7 # header |
| 8 print(FMT.format(name='name', value='value', description='description')) |
| 9 print('-' * (33)) |
| 10 |
| 11 for name, value in [(signal_name, getattr(signal, signal_name)) |
| 12 for signal_name in dir(signal) |
| 13 if signal_name.startswith('SIG') |
| 14 and not signal_name.startswith('SIG_')]: |
| 15 try: |
| 16 handler = signal.getsignal(value) |
| 17 except ValueError: |
| 18 # FreeBSD: signal number out of range |
| 19 handler = 'out of range' |
| 20 description = { |
| 21 signal.SIG_IGN: "ignored(SIG_IGN)", |
| 22 signal.SIG_DFL: "default(SIG_DFL)" |
| 23 }.get(handler, handler) |
| 24 print(FMT.format(name=name, value=value, description=description)) |
OLD | NEW |