Mercurial > hg > audiodb
comparison audioDB.cpp @ 104:97107ee61dba
Temporary signal handling.
"Temporary" because it will not work on platforms which don't have real
signals (Hello, Win32) but nevertheless useful, as otherwise gcov (the
code coverage tool) will not count executions of processes that are
killed by signals (in particular, the server processes started in the
tests).
A brief experiment suggests that we're up to about 80% statement
coverage from our 20 tests.
author | mas01cr |
---|---|
date | Thu, 04 Oct 2007 15:02:29 +0000 |
parents | 69424e77621f |
children | 10feb98abebf |
comparison
equal
deleted
inserted
replaced
103:2c58d5193287 | 104:97107ee61dba |
---|---|
1 #include "audioDB.h" | 1 #include "audioDB.h" |
2 | |
3 void sigterm_action(int signal, siginfo_t *info, void *context) { | |
4 exit(128+signal); | |
5 } | |
6 | |
7 void sighup_action(int signal, siginfo_t *info, void *context) { | |
8 // FIXME: reread any configuration files | |
9 } | |
2 | 10 |
3 #define O2_DEBUG | 11 #define O2_DEBUG |
4 | 12 |
5 void audioDB::error(const char* a, const char* b, const char *sysFunc) { | 13 void audioDB::error(const char* a, const char* b, const char *sysFunc) { |
6 if(isServer) { | 14 if(isServer) { |
194 command=COM_SERVER; | 202 command=COM_SERVER; |
195 port=args_info.SERVER_arg; | 203 port=args_info.SERVER_arg; |
196 if(port<100 || port > 100000) | 204 if(port<100 || port > 100000) |
197 error("port out of range"); | 205 error("port out of range"); |
198 isServer=1; | 206 isServer=1; |
207 struct sigaction sa; | |
208 sa.sa_sigaction = sigterm_action; | |
209 sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; | |
210 sigaction(SIGTERM, &sa, NULL); | |
211 sa.sa_sigaction = sighup_action; | |
212 sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; | |
213 sigaction(SIGHUP, &sa, NULL); | |
199 return 0; | 214 return 0; |
200 } | 215 } |
201 | 216 |
202 // No return on client command, find database command | 217 // No return on client command, find database command |
203 if(args_info.client_given){ | 218 if(args_info.client_given){ |
2608 } | 2623 } |
2609 | 2624 |
2610 int main(const unsigned argc, char* const argv[]){ | 2625 int main(const unsigned argc, char* const argv[]){ |
2611 audioDB(argc, argv); | 2626 audioDB(argc, argv); |
2612 } | 2627 } |
2628 |