# HG changeset patch # User mas01cr # Date 1191510149 0 # Node ID 97107ee61dba8e141d21d14a6d41b22023f8b59b # Parent 2c58d51932877d66012fe5d928629479f803ed2c 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. diff -r 2c58d5193287 -r 97107ee61dba audioDB.cpp --- a/audioDB.cpp Thu Oct 04 10:38:32 2007 +0000 +++ b/audioDB.cpp Thu Oct 04 15:02:29 2007 +0000 @@ -1,5 +1,13 @@ #include "audioDB.h" +void sigterm_action(int signal, siginfo_t *info, void *context) { + exit(128+signal); +} + +void sighup_action(int signal, siginfo_t *info, void *context) { + // FIXME: reread any configuration files +} + #define O2_DEBUG void audioDB::error(const char* a, const char* b, const char *sysFunc) { @@ -196,6 +204,13 @@ if(port<100 || port > 100000) error("port out of range"); isServer=1; + struct sigaction sa; + sa.sa_sigaction = sigterm_action; + sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; + sigaction(SIGTERM, &sa, NULL); + sa.sa_sigaction = sighup_action; + sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; + sigaction(SIGHUP, &sa, NULL); return 0; } @@ -2610,3 +2625,4 @@ int main(const unsigned argc, char* const argv[]){ audioDB(argc, argv); } + diff -r 2c58d5193287 -r 97107ee61dba audioDB.h --- a/audioDB.h Thu Oct 04 10:38:32 2007 +0000 +++ b/audioDB.h Thu Oct 04 15:02:29 2007 +0000 @@ -11,6 +11,7 @@ #include #include #include +#include // includes for web services #include "soapH.h"