I am trying to do interruption handling with a member function from a class.
The code is
signal(SIGABRT, socketServer.signalHandler);
where the definition of signalHandler
is
public:
void SocketServer::signalHandler(int sig)
{
logger.info("Receive SIG"+to_string(sig)+" Stopping server now...");
stop();
}
When I compile the code, I got an error says
main.cpp:32:32: error: reference to non-static member function must be called
signal(SIGABRT, socketServer.signalHandler);
I am trying to capture SIGABRT
using this signalHandler
function and to clean up and stop the socketServer
instance. I guess I can use global variable and a global function to do the job, but any thoughts about doing this with a member function?