Skip to main content

Module unix

Module unix 

Source
Expand description

Unix signals as streams: signal listens to one SignalKind.

The first listener of a signal installs the process’s handler for it (SA_SIGINFO | SA_RESTART | SA_ONSTACK), which stays for good and chains to the handler that was there before. The handler raises the signal’s count, then writes to the process’s wake descriptor: an eventfd on Linux, a pipe elsewhere, made once, non-blocking, and never closed, so a handler never writes to a descriptor that went or that another file reuses. Both are async-signal-safe; errno is kept.

Each shard a listener is polled on runs a pump: a task of the runtime’s own that reads the wake descriptor through the shard’s driver and then dispatches. The pump drains the descriptor before it looks at the counts, and the handler raises the count before it writes, so a delivery whose write the pump read is in the counts it sees, and a later one writes again. A listener polled where no shard runs is served by a pump on a runtime worker.

Structs§

Signal
The deliveries of one signal, as a stream: each item stands for one delivery or more since the item before.
SignalKind
A unix signal a Signal listens to.

Functions§

signal
Listens to kind from now on.