#include "shared/shared.hh" namespace shared { bool should_exit = false; static void set_signal(const decltype(SIGINT) signal, void (*const callback)(const int)) { struct sigaction sa {}; sa.sa_handler = callback; if (sigaction(signal, &sa, nullptr) == -1) { throw std::runtime_error("failed to set signal handler!"); } } void set_exit_handler() { set_signal(SIGPIPE, SIG_IGN); set_signal(SIGINT, [](const int) { std::cout << " interrupt signal received\n"; should_exit = true; }); } } // namespace shared