![]() |
algotradelib 0.0.0.9000
C++ header-only library for algorithmic trading
|
Routes SIGINT and SIGTERM to a StopSource as a quiesce, and ignores SIGHUP where it exists (POSIX); only when install is called. More...
#include <algotradelib/src/runner/signal_stop.hpp>
Static Public Member Functions | |
| static void | install (StopSource &source) noexcept |
| Installs the handlers: SIGINT and SIGTERM request a quiesce on source; SIGHUP, where it exists, is ignored. | |
| static void | uninstall () noexcept |
| Restores the default disposition of SIGINT, SIGTERM and (POSIX) SIGHUP, and forgets the source. | |
| static StopSource * | installed () noexcept |
| Returns the installed source. | |
Routes SIGINT and SIGTERM to a StopSource as a quiesce, and ignores SIGHUP where it exists (POSIX); only when install is called.
Both signals mean StopIntent::QUIESCE, never a flatten, since they arrive for routine reasons (a reboot, a deploy, Ctrl+C). SIGHUP is ignored so a dropped SSH session does not stop a process holding positions; Windows has no SIGHUP.
| Situation | What arrives |
|---|---|
| tmux send-keys -t sess:0.0 C-c | SIGINT to the foreground process |
| kill -TERM <pid> | SIGTERM |
| host reboot under systemd | SIGTERM, then SIGKILL after TimeoutStopSec |
| docker stop | SIGTERM, then SIGKILL after ten seconds |
Definition at line 30 of file signal_stop.hpp.
|
inlinestaticnoexcept |
Installs the handlers: SIGINT and SIGTERM request a quiesce on source; SIGHUP, where it exists, is ignored.
Only one source can be installed at a time.
| source | The stop source; it must outlive the handlers (until uninstall). |
Definition at line 40 of file signal_stop.hpp.
|
inlinestaticnoexcept |
Returns the installed source.
Definition at line 64 of file signal_stop.hpp.
|
inlinestaticnoexcept |
Restores the default disposition of SIGINT, SIGTERM and (POSIX) SIGHUP, and forgets the source.
Definition at line 51 of file signal_stop.hpp.