Expand description
Stop fan-in for a daemon host (issue #375): one StopSource that several inputs may
trigger (an OS stop signal, the parent closing this process’s stdin, or the program itself),
and StopTokens that the host’s threads wait on. The first cause wins and later triggers
are ignored.
Signals: stop_on_signals installs handlers for SIGINT and SIGTERM on Unix and the console
control handler on Windows (Ctrl+C, Ctrl+Break, close). The handler only records the event in a
static atomic (the one thing a signal handler may do here); a watcher thread turns that into a
trigger, polling every 50 ms, and exits once the source is stopped. Other platforms return
Unsupported.
Stdin: stop_on_stdin_close triggers the source when stdin reaches end of file (see
crate::private::watch_stdin_eof).
Structs§
- Parent
Fence - A parent-process identity fence: the parent’s pid pinned to its OS start marker, so a
different process that later reuses the pid is never mistaken for the parent. A child
whose parent cannot hold its stdin open (or must not rely on it alone) captures this at
start and stops itself when
parent_goneturns true; conversely a reused pid alone can neither keep the child alive nor claim to be its parent. - Stop
Source - The trigger side. Clone it to give inputs their own handle; every clone triggers the same stop.
- Stop
Token - The waiting side. Cheap to clone; it sees the stop that its source triggers.
Enums§
- Stop
Cause - Why the stop was triggered. The first trigger’s cause is the one reported.
Functions§
- stop_
on_ signals - Install OS stop-signal handlers that trigger
source(see the module docs). The watcher thread ends when the source is stopped by any input. - stop_
on_ stdin_ close - Trigger
sourcewhen this process’s stdin reaches end of file. - stop_
when_ parent_ gone - Trigger
sourcewithStopCause::ParentGoneoncefence’s parent is gone. Polls everypoll(raised to at least 10 ms); the watcher thread ends when the source is stopped by any input.