Python Glossary Русский

all Python 3Linux · macOSosfunction

os.WIFSTOPPED

os — status decoding (W*)

Test whether a child was stopped (not terminated). Availability: Unix.

Syntax

os.WIFSTOPPED(...)

A stopped process is alive and may continue — it has not exited. This status arrives only when waiting with WUNTRACED or when the process is traced. Do not confuse it with exit: a stopped process has no exit code, and waitstatus_to_exitcode raises ValueError for it.

Examples

import os
print(os.WIFSTOPPED(0x137f))   # → True — младший байт статуса равен 0x7f, это признак остановки
print(os.WIFSTOPPED(9))   # → False — такой статус означает завершение сигналом, а не остановку
pid, status = os.waitpid(-1, os.WUNTRACED)   # → ? только Unix: без флага WUNTRACED об остановке ребёнка узнать нельзя
print(os.WIFSTOPPED(status))   # → True, если ребёнок остановлен (например по SIGSTOP), а не завершён
print(os.WSTOPSIG(status) if os.WIFSTOPPED(status) else None)   # → ? только Unix: номер остановившего сигнала имеет смысл только при истинном WIFSTOPPED

See also

Open in the full glossarydocs.python.orgReport an inaccuracy