00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include "ArExport.h"
00054 #include "ariaOSDef.h"
00055 #include "ArSignalHandler.h"
00056 #include "ArLog.h"
00057
00058
00059 ArSignalHandler *ArSignalHandler::ourSignalHandler=0;
00060 ArStrMap ArSignalHandler::ourSigMap;
00061 std::list<ArFunctor1<int>*> ArSignalHandler::ourHandlerList;
00062
00063
00064 void ArSignalHandler::signalCB(int sig)
00065 {
00066 std::list<ArFunctor1<int>*>::iterator iter;
00067
00068 for (iter=ourHandlerList.begin(); iter != ourHandlerList.end(); ++iter)
00069 (*iter)->invoke(sig);
00070 if (ourHandlerList.begin() == ourHandlerList.end())
00071 ArLog::log(ArLog::Terse, "ArSignalHandler::runThread: No handler function. Unhandled signal '%s'", ourSigMap[sig].c_str());
00072 }
00073
00074 void ArSignalHandler::createHandlerNonThreaded()
00075 {
00076 }
00077
00078 void ArSignalHandler::createHandlerThreaded()
00079 {
00080 getHandler()->create(false);
00081 }
00082
00083 void ArSignalHandler::blockCommon()
00084 {
00085 }
00086
00087 void ArSignalHandler::unblockAll()
00088 {
00089 }
00090
00091 void ArSignalHandler::block(Signal sig)
00092 {
00093 }
00094
00095 void ArSignalHandler::unblock(Signal sig)
00096 {
00097 }
00098
00099 void ArSignalHandler::handle(Signal sig)
00100 {
00101 }
00102
00103 void ArSignalHandler::unhandle(Signal sig)
00104 {
00105 }
00106
00107 void ArSignalHandler::addHandlerCB(ArFunctor1<int> *func,
00108 ArListPos::Pos position)
00109 {
00110 if (position == ArListPos::FIRST)
00111 ourHandlerList.push_front(func);
00112 else if (position == ArListPos::LAST)
00113 ourHandlerList.push_back(func);
00114 else
00115 ArLog::log(ArLog::Terse,
00116 "ArSignalHandler::addHandler: Invalid position.");
00117 }
00118
00119 void ArSignalHandler::delHandlerCB(ArFunctor1<int> *func)
00120 {
00121 ourHandlerList.remove(func);
00122 }
00123
00124 ArSignalHandler * ArSignalHandler::getHandler()
00125 {
00126 if (!ourSignalHandler)
00127 ourSignalHandler=new ArSignalHandler;
00128
00129 return(ourSignalHandler);
00130 }
00131
00132 void ArSignalHandler::blockCommonThisThread()
00133 {
00134 }
00135
00136 void ArSignalHandler::blockAllThisThread()
00137 {
00138 }
00139
00140 ArSignalHandler::ArSignalHandler()
00141 {
00142 setThreadName("ArSignalHandler");
00143 initSigMap();
00144 }
00145
00146 ArSignalHandler::~ArSignalHandler()
00147 {
00148 }
00149
00150 void * ArSignalHandler::runThread(void *arg)
00151 {
00152 threadStarted();
00153 return(0);
00154 }
00155
00156 void ArSignalHandler::initSigMap()
00157 {
00158 ourSigMap[SigHUP]="SIGHUP";
00159 ourSigMap[SigINT]="SIGINT";
00160 ourSigMap[SigQUIT]="SIGQUIT";
00161 ourSigMap[SigILL]="SIGILL";
00162 ourSigMap[SigTRAP]="SIGTRAP";
00163 ourSigMap[SigABRT]="SIGABRT";
00164
00165 ourSigMap[SigBUS]="SIGBUS";
00166 ourSigMap[SigFPE]="SIGFPE";
00167 ourSigMap[SigKILL]="SIGKILL";
00168 ourSigMap[SigUSR1]="SIGUSR1";
00169 ourSigMap[SigSEGV]="SIGSEGV";
00170 ourSigMap[SigUSR2]="SIGUSR2";
00171 ourSigMap[SigPIPE]="SIGPIPE";
00172 ourSigMap[SigALRM]="SIGALRM";
00173 ourSigMap[SigTERM]="SIGTERM";
00174
00175 ourSigMap[SigCHLD]="SIGCHLD";
00176 ourSigMap[SigCONT]="SIGCONT";
00177 ourSigMap[SigSTOP]="SIGSTOP";
00178 ourSigMap[SigTSTP]="SIGTSTP";
00179 ourSigMap[SigTTIN]="SIGTTIN";
00180 ourSigMap[SigTTOU]="SIGTTOU";
00181 ourSigMap[SigURG]="SIGURG";
00182 ourSigMap[SigXCPU]="SIGXCPU";
00183 ourSigMap[SigXFSZ]="SIGXFSZ";
00184 ourSigMap[SigVTALRM]="SIGVTALRM";
00185 ourSigMap[SigPROF]="SIGPROF";
00186 ourSigMap[SigWINCH]="SIGWINCH";
00187 ourSigMap[SigIO]="SIGIO";
00188 ourSigMap[SigPWR]="SIGPWR";
00189 }
00190
00191 const char * ArSignalHandler::nameSignal(int sig)
00192 {
00193 return(ourSigMap[sig].c_str());
00194 }
00195
00196 void ArSignalHandler::logThread(void)
00197 {
00198 if (ourSignalHandler != NULL)
00199 ourSignalHandler->logThreadInfo();
00200 else
00201 ArLog::log(ArLog::Normal, "No signal handler thread running");
00202 }