信号函数调用静态函数问题
信号函数调用类static成员函数,成员函数调用static成员。
#include <iostream>#include <map>using namespace std;typedef std::map<int,int> INTMAP;class CStTest{ public: CStTest(){}; ~CStTest(){}; public: static void put() { a=5; } static int *get() { return &a; } INTMAP *GetMap() { return &initmap; } public: static int a; static INTMAP initmap;};CStTest *g_pModule;#include "stTest.h"#include <signal.h>void SigCapture(int sig){ int a = *(CStTest::get()); g_pModule->GetMap().clear(); }int main(){ signal(SIGHUP, SigCapture); signal(SIGINT, SigCapture); signal(SIGTERM, SigCapture); signal(SIGABRT, SigCapture); CStTest *pModule = new CStTest; g_pModule = pModule; int a=1; int b=2; pModule->initmap.insert(make_pair(a,b)); delete pModule;}