1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-13 03:30:33 +00:00

Add SIGTERM to control_thread signal handler

This commit is contained in:
Javier Arribas 2023-10-03 11:02:05 +02:00
parent 59d70eb338
commit 559e570cbc

View File

@ -89,15 +89,15 @@ ControlThread *ControlThread::me = nullptr;
void ControlThread::handle_signal(int sig) void ControlThread::handle_signal(int sig)
{ {
DLOG(INFO) << "GNSS-SDR received " << sig << " OS signal"; DLOG(INFO) << "GNSS-SDR received " << sig << " OS signal";
if (sig == SIGINT) if (sig == SIGINT || sig == SIGTERM)
{ {
std::cout << "Stopping GNSS-SDR via SIGINT...\n"; std::cout << "Stopping GNSS-SDR via SIGINT or SIGTERM...\n";
ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0))); ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0)));
ControlThread::me->stop_ = true; ControlThread::me->stop_ = true;
/* Reset signal handling to default behavior */ /* Reset signal handling to default behavior */
signal(SIGINT, SIG_DFL); if (sig == SIGINT) signal(SIGINT, SIG_DFL);
} }
else if (sig == SIGHUP) else if (sig == SIGHUP)
{ {
@ -117,8 +117,9 @@ ControlThread::ControlThread()
{ {
ControlThread::me = this; ControlThread::me = this;
/* the class will handle two signals */ /* the class will handle signals */
signal(SIGINT, ControlThread::handle_signal); signal(SIGINT, ControlThread::handle_signal);
signal(SIGTERM, ControlThread::handle_signal);
signal(SIGHUP, ControlThread::handle_signal); signal(SIGHUP, ControlThread::handle_signal);
if (FLAGS_c == "-") if (FLAGS_c == "-")