00001
00002
00003 #ifndef BASE_SIGNAL_H
00004 #define BASE_SIGNAL_H
00005
00006 #ifdef _WIN32
00007 #define WIN32_LEAN_AND_MEAN
00008 #include <windows.h>
00009 #endif
00010 #include <csignal>
00011 #include <map>
00012 #include "IOException.h"
00013
00014 namespace base {
00016
00022 class PPBASE_EXPORT Signal {
00023 public:
00024 static volatile int _alarm;
00025 static volatile int _child;
00026 static volatile int _quit;
00027 static volatile int _restart;
00028 static volatile int _reread;
00029 static volatile int _user1;
00030 static volatile int _user2;
00031
00033
00037 static void handle(int sig, void (*handler)(int));
00038
00040
00043 static void handle(int sig);
00044
00046
00049 static void ignore(int sig);
00050
00052
00058 static void setDefaults();
00059
00061 static void signal_handler(int sig);
00062
00063 #ifdef _WIN32
00064 static DWORD _tid;
00065 static UINT _tmsg;
00066
00068
00072 static void setThreadMsg(DWORD tid, UINT msg = WM_QUIT);
00073 #else
00074
00075 typedef void (*ioEventHandler)(int, int, void*);
00076
00078 static std::map<int, std::pair<ioEventHandler, void*> > _ioeh;
00079
00081
00086 static void addEventHandler(int fd, ioEventHandler handler, void *user);
00087
00089
00092 static void delEventHandler(int fd);
00093
00095
00098 static void handleIO(int sig = SIGIO);
00099
00101 static void handleIOEvents();
00102
00104
00109 static void handlerIO(int sig, siginfo_t *info, void *ctx);
00110 #endif
00111 };
00112 }
00113
00114 #endif