Python Glossary Русский

Python 3.3+Linuxsignalterm

signal.struct_siginfo

masks and waiting

The result type of sigwaitinfo and sigtimedwait: a named tuple with si_signo, si_code, si_pid, si_uid and more. Linux.

Syntax

info.si_signo, info.si_pid, info.si_uid

There is no reason to build one yourself — it only comes out of sigwaitinfo/sigtimedwait. It is a struct sequence: fields work by name and by index, and unpacking yields all seven values. si_status and si_band only mean something for particular signals (SIGCHLD, SIGPOLL); otherwise they hold zero or junk. si_signo is a plain int; signal.Signals(info.si_signo) gives the name.

Examples

import os, signal
old = signal.pthread_sigmask(signal.SIG_BLOCK, {signal.SIGUSR1})
signal.raise_signal(signal.SIGUSR1)
info = signal.sigwaitinfo({signal.SIGUSR1})
print(type(info).__name__, len(info))  # → struct_siginfo 7
print(signal.Signals(info.si_signo).name, info[0] == info.si_signo)  # → SIGUSR1 True
print(info.si_pid)  # → ? PID этого процесса
signal.pthread_sigmask(signal.SIG_SETMASK, old)

See also

Open in the full glossarydocs.python.orgReport an inaccuracy