aboutsummaryrefslogtreecommitdiff
path: root/src/tests/signaltest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/signaltest.cc')
-rw-r--r--src/tests/signaltest.cc66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/tests/signaltest.cc b/src/tests/signaltest.cc
index 7d0b53a..27f82eb 100644
--- a/src/tests/signaltest.cc
+++ b/src/tests/signaltest.cc
@@ -28,48 +28,48 @@ using namespace FbTk;
28 28
29class IntSig:public SignalHandler::EventHandler { 29class IntSig:public SignalHandler::EventHandler {
30public: 30public:
31 void handleSignal(int signum) { 31 void handleSignal(int signum) {
32 assert(signum == SIGINT); 32 assert(signum == SIGINT);
33 cerr<<"Signal SIGINT!"<<endl; 33 cerr<<"Signal SIGINT!"<<endl;
34 exit(0); 34 exit(0);
35 } 35 }
36}; 36};
37 37
38class AllSig:public SignalHandler::EventHandler { 38class AllSig:public SignalHandler::EventHandler {
39public: 39public:
40 void handleSignal(int signum) { 40 void handleSignal(int signum) {
41 switch (signum) { 41 switch (signum) {
42 case SIGTERM: 42 case SIGTERM:
43 cerr<<"SIGTERM"; 43 cerr<<"SIGTERM";
44 break; 44 break;
45 case SIGUSR1: 45 case SIGUSR1:
46 cerr<<"SIGUSR1"; 46 cerr<<"SIGUSR1";
47 break; 47 break;
48 case SIGUSR2: 48 case SIGUSR2:
49 cerr<<"SIGUSR2"; 49 cerr<<"SIGUSR2";
50 break; 50 break;
51 default: 51 default:
52 cerr<<"signum = "<<signum; 52 cerr<<"signum = "<<signum;
53 } 53 }
54 cerr<<endl; 54 cerr<<endl;
55 if (signum == SIGTERM) 55 if (signum == SIGTERM)
56 exit(1); // end program 56 exit(1); // end program
57 } 57 }
58}; 58};
59 59
60int main(int argc, char **argv) { 60int main(int argc, char **argv) {
61 SignalHandler *sigh = SignalHandler::instance(); 61 SignalHandler *sigh = SignalHandler::instance();
62 IntSig handler; 62 IntSig handler;
63 AllSig allhand; 63 AllSig allhand;
64 64
65 sigh->registerHandler(SIGINT, &handler); 65 sigh->registerHandler(SIGINT, &handler);
66 sigh->registerHandler(SIGTERM, &allhand); 66 sigh->registerHandler(SIGTERM, &allhand);
67 sigh->registerHandler(SIGUSR1, &allhand); 67 sigh->registerHandler(SIGUSR1, &allhand);
68 sigh->registerHandler(SIGUSR2, &allhand); 68 sigh->registerHandler(SIGUSR2, &allhand);
69 cerr<<"Send signals to me :)"<<endl; 69 cerr<<"Send signals to me :)"<<endl;
70 while (1) { 70 while (1) {
71 71
72 } 72 }
73} 73}
74 74
75 75