parent
53d7d7b1d8
commit
2f80b3573b
|
@ -4,11 +4,30 @@
|
|||
#include <fmt/core.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <csignal>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <thread>
|
||||
|
||||
void signal_handler(int signum)
|
||||
{
|
||||
switch (signum)
|
||||
{
|
||||
case SIGTERM:
|
||||
case SIGINT:
|
||||
{
|
||||
std::cout << "\n<span color='red'>Time script terminated.</span>\n";
|
||||
std::exit(signum); // NOLINT(concurrency-mt-unsafe)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using fmt::format;
|
||||
|
@ -20,6 +39,9 @@ int main()
|
|||
// Set explicitly, because LC_TIME is en_DK.UTF-8.
|
||||
std::locale::global(std::locale("de_DE.UTF-8"));
|
||||
|
||||
std::signal(SIGINT, signal_handler);
|
||||
std::signal(SIGTERM, signal_handler);
|
||||
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
|
|
Loading…
Reference in New Issue