all Python 3Linux · macOSosfunction
os.WSTOPSIG
os — status decoding (W*)
Return the signal number that stopped a child. Availability: Unix.
Syntax
os.WSTOPSIG(...)
It is meaningful only after WIFSTOPPED is true. Usually it is SIGSTOP or SIGTSTP — the latter arrives when the user presses Ctrl+Z. Debuggers see SIGTRAP here at every stop of a traced process.
Examples
import os
status = 0x137f # статус, каким его вернул os.waitpid() для процесса, остановленного сигналом SIGSTOP
print(os.WSTOPSIG(status)) # → 19 — номер SIGSTOP на Linux, он лежит в старшем байте статуса
print(os.WSTOPSIG(0x057f)) # → 5 — SIGTRAP, так процесс останавливает отладчик
pid, status = os.waitpid(-1, os.WUNTRACED) # → ? только Unix: дождаться ребёнка, в том числе остановленного, а не только завершённого
print(os.WSTOPSIG(status) if os.WIFSTOPPED(status) else 0) # → ? только Unix: на не-остановленном статусе результат WSTOPSIG бессмыслен, поэтому проверка WIFSTOPPED обязательна
See also
Open in the full glossarydocs.python.orgReport an inaccuracy