Expand description
Signals (unix) and console control events (Windows), as streams.
Signals: a stream of the deliveries of one signal (unix) or console
control event (Windows), and ctrl_c.
Each signal has a count of its deliveries, which the process’s handler raises. A listener remembers the count it last saw: a poll that finds the count moved is one item, however many deliveries that was. A listener that waits registers its waker, then looks at the count once more; whoever dispatches looks at the count after the delivery raised it, then wakes the listeners of each signal whose count moved, so no delivery is missed (the register-then-look pattern of the sync module).
On unix a signal handler may do little: it raises the count and writes
to one wake descriptor of the process, never closed, which every shard
with a listener reads through a pump task of its own and then
dispatches (see unix). On Windows the console control handler runs on
a thread of its own and dispatches itself.
Modules§
- unix
- Unix signals as streams:
signallistens to oneSignalKind.
Functions§
- ctrl_c
- Completes once the process gets a Ctrl-C:
SIGINTon unix, the console’sCTRL_C_EVENTon Windows. Listening starts with the first poll; on unix the default action ofSIGINT(ending the process) is replaced for good from then on.