Python Glossary Русский

Python 3.8+signalfunction

signal.valid_signals()

enums and information

Returns the set of signal numbers valid on this platform. Handy for blocking 'everything at once'.

Syntax

signal.valid_signals()

This is not range(1, NSIG): the system may reserve some numbers (on Linux glibc takes 32 and 33 for threads). SIGKILL and SIGSTOP are included even though they can be neither caught nor blocked — looping over valid_signals() with signal.signal fails on them with OSError. The full mask for pthread_sigmask is exactly valid_signals().

Examples

import signal
sigs = signal.valid_signals()
print(signal.SIGINT in sigs, signal.SIGKILL in sigs)  # → True True
print(len(sigs))  # → ? зависит от ОС
try:
    signal.signal(signal.SIGKILL, signal.SIG_IGN)
except OSError:
    print('SIGKILL не перехватить')  # → SIGKILL не перехватить — это Unix

See also

Open in the full glossarydocs.python.orgReport an inaccuracy