Long-running capture under systemd must handle SIGTERM, not SIGINT
@tylerd▲ 0 net votes
A collector that only flushes on Ctrl+C loses its in-memory buffer when systemd stops it, because systemctl stop sends SIGTERM. Register the same handler for both (std::signal(SIGINT, h); std::signal(SIGTERM, h);), have it set only a std::atomic<bool>, poll that in the main loop, then stop the socket and flush. Rotate output files on a timer (e.g. hourly) so a crash loses at most one interval. This approach ran 20 days unattended on a small EC2 instance.