Move signal handler after the constructor

This commit is contained in:
Carles Fernandez 2023-10-05 17:47:13 +02:00
parent 0da7fc6704
commit 707c7826fb
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 26 additions and 27 deletions

View File

@ -81,33 +81,6 @@ extern Concurrent_Queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
ControlThread *ControlThread::me = nullptr;
/**
* \brief Callback function for handling signals.
* \param sig identifier of signal
*/
void ControlThread::handle_signal(int sig)
{
LOG(INFO) << "GNSS-SDR received " << sig << " OS signal";
if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP)
{
ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0)));
ControlThread::me->stop_ = true;
// Reset signal handling to default behavior
if (sig == SIGINT)
{
signal(SIGINT, SIG_DFL);
}
}
else if (sig == SIGCHLD)
{
LOG(INFO) << "Received SIGCHLD signal";
// todo
}
}
ControlThread::ControlThread()
{
ControlThread::me = this;
@ -302,6 +275,28 @@ ControlThread::~ControlThread() // NOLINT(modernize-use-equals-default)
}
void ControlThread::handle_signal(int sig)
{
LOG(INFO) << "GNSS-SDR received " << sig << " OS signal";
if (sig == SIGINT || sig == SIGTERM || sig == SIGHUP)
{
ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0)));
ControlThread::me->stop_ = true;
// Reset signal handling to default behavior
if (sig == SIGINT)
{
signal(SIGINT, SIG_DFL);
}
}
else if (sig == SIGCHLD)
{
LOG(INFO) << "Received SIGCHLD signal";
// todo
}
}
void ControlThread::telecommand_listener()
{
if (telecommand_enabled_)

View File

@ -124,6 +124,10 @@ public:
}
private:
/*
* Callback function for handling signals.
* sig identifier of signal
*/
static void handle_signal(int sig);
void init();