Signal handling.
| Name | Description |
|---|---|
| flags | Flags for signalfds and signal handlers. |
| signals | Known signal constants. |
| Kind | Name | Description |
|---|---|---|
| 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 |
| Struct | Signal | A signal. |
| Struct | Sigset | A set of signals. |
| Name | Description |
|---|---|
| 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. |
Signals can be in one of three states:
Unblocked
Blocked
Ignored
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:
The process is terminated
The process is terminated and a core-dump is generated
The process is stopped
A signal handler is invoked
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.