Python 3.8+signalfunction
signal.strsignal()
enums and information
Returns the OS description of a signal: 'Interrupt' for SIGINT, 'Killed' for SIGKILL. Useful for readable messages.
Syntax
signal.strsignal(signalnum)
The text comes from libc and depends on the system: Linux and macOS phrase it differently, and on Windows many signals return None — so compare numbers or .name in code and keep strsignal for messages. A negative subprocess return code (-9) means death by signal: strsignal(-returncode) explains it to a human. A number out of range raises ValueError.
Examples
import signal
print(signal.strsignal(signal.SIGINT)) # → Interrupt
print(signal.strsignal(9)) # → ? Killed на Linux
try:
signal.strsignal(1000)
except ValueError as e:
print(e) # → signal number out of range
See also
Open in the full glossarydocs.python.orgReport an inaccuracy