Module lrs::signal

Signal handling.

Sub-modules

NameDescription
flags

Flags for signalfds and signal handlers.

signals

Known signal constants.

Types

KindNameDescription
Enum SigHandler

A signal handler.

Struct SigInfo

Information about a received signal.

Struct Sigfd

A signalfd.

Struct SigfdFlags

Flags that can be used when creating a Sigfd.

Struct SigfdInfo

Information about a signal received via a Sigfd.

Struct Signal

A signal.

Struct Sigset

A set of signals.

Functions

NameDescription
block_signal

Blocks a signal from this thread.

block_signals

Blocks a set of signals from this thread.

blocked_signals

Returns the set of signals that are blocked by this thread.

pending_signals

Returns the set of blocked signals that are currently blocked from this thread.

send

Sends a signal to a process.

send_to_thread

Sends a signal to a thread.

set_blocked_signals

Sets the set of signals that are blocked from this thread.

set_handler

Sets the handler of a signal.

suspend_with

Replaces the set of blocked signals and suspends the calling thread until a signal handler is invoked.

unblock_signal

Unblocks a signal from this thread.

unblock_signals

Unblocks a set of signals from this thread.

wait

Suspends the calling thread until a certain signal arrives.

wait_timeout

Suspends the calling thread until a certain signal arrives or a timeout expires.

Remarks

Signals can be in one of three states:

Note that Ignored is a state that applies to the whole process while Blocked only applies to a single thread. If an ignored signal is sent to a thread or process, it is discarded.

If a signal is sent to a thread and the thread has the signal blocked, it is queued until the signal unblocks it or retrieves it in some other way. The same principle applies if a signal is sent to a process and all threads have the signal blocked.

If a signal is sent to a thread that has the signal unblocked or to a process where at least one thread has the signal unblocked, one of the following actions is taken:

By default, signal handlers are invoked on the stack of the thread that handles the signal. It is possible to use a separate stack which is necessary to handle invalid address access caused by stack overflow.

See also