mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-03-04 10:38:17 +00:00
Adding standard UNIX/POSIX signals listener. GNSS-SDR now can be safely stopped using CTL+C
This commit is contained in:
parent
a39144105c
commit
b971b61eed
@ -78,9 +78,49 @@ namespace wht = std;
|
|||||||
extern Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
extern Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
||||||
extern Concurrent_Queue<Gps_Acq_Assist> global_gps_acq_assist_queue;
|
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)
|
||||||
|
{
|
||||||
|
if (sig == SIGINT)
|
||||||
|
{
|
||||||
|
std::cout << "Stopping GNSS-SDR via SIGINT...\n";
|
||||||
|
|
||||||
|
ControlThread::me->control_queue_->push(pmt::make_any(command_event_make(200, 0)));
|
||||||
|
ControlThread::me->stop_ = true;
|
||||||
|
|
||||||
|
/* Reset signal handling to default behavior */
|
||||||
|
signal(SIGINT, SIG_DFL);
|
||||||
|
}
|
||||||
|
else if (sig == SIGHUP)
|
||||||
|
{
|
||||||
|
|
||||||
|
std::cout << "Debug: received SIGHUP signal\n";
|
||||||
|
//std::cout << "Debug: reloading daemon config file ...\n";
|
||||||
|
//todo
|
||||||
|
}
|
||||||
|
else if (sig == SIGCHLD)
|
||||||
|
{
|
||||||
|
std::cout << "Debug: received SIGCHLD signal\n";
|
||||||
|
//todo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ControlThread::ControlThread()
|
ControlThread::ControlThread()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ControlThread::me=this;
|
||||||
|
|
||||||
|
/* the class will handle two signals */
|
||||||
|
signal(SIGINT, ControlThread::handle_signal);
|
||||||
|
signal(SIGHUP, ControlThread::handle_signal);
|
||||||
|
|
||||||
if (FLAGS_c == "-")
|
if (FLAGS_c == "-")
|
||||||
{
|
{
|
||||||
configuration_ = std::make_shared<FileConfiguration>(FLAGS_config_file);
|
configuration_ = std::make_shared<FileConfiguration>(FLAGS_config_file);
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <typeinfo> // for std::type_info, typeid
|
#include <typeinfo> // for std::type_info, typeid
|
||||||
#include <utility> // for pair
|
#include <utility> // for pair
|
||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
#ifdef ENABLE_FPGA
|
#ifdef ENABLE_FPGA
|
||||||
#include <boost/thread.hpp> // for boost::thread
|
#include <boost/thread.hpp> // for boost::thread
|
||||||
@ -54,6 +55,7 @@ class ConfigurationInterface;
|
|||||||
class GNSSFlowgraph;
|
class GNSSFlowgraph;
|
||||||
class Gnss_Satellite;
|
class Gnss_Satellite;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief This class represents the main thread of the application, so the name is ControlThread.
|
* \brief This class represents the main thread of the application, so the name is ControlThread.
|
||||||
* This is the GNSS Receiver Control Plane: it connects the flowgraph, starts running it,
|
* This is the GNSS Receiver Control Plane: it connects the flowgraph, starts running it,
|
||||||
@ -63,6 +65,8 @@ class Gnss_Satellite;
|
|||||||
class ControlThread
|
class ControlThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static ControlThread* me;
|
||||||
/*!
|
/*!
|
||||||
* \brief Default constructor
|
* \brief Default constructor
|
||||||
*/
|
*/
|
||||||
@ -122,6 +126,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
static void handle_signal(int sig);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
void apply_action(unsigned int what);
|
void apply_action(unsigned int what);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user