From: Pierre Habouzit Date: Thu, 30 Aug 2007 22:19:27 +0000 (+0200) Subject: Better handling of forking and exiting and signals. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=e3d9a582b6ff0bef16a6c1e7f506d9088379c77a;p=apps%2Fpfixtools.git Better handling of forking and exiting and signals. Signed-off-by: Pierre Habouzit --- diff --git a/common.c b/common.c index 13adb2d..7ede07b 100644 --- a/common.c +++ b/common.c @@ -55,19 +55,14 @@ void common_sighandler(int sig) } return; - case SIGTERM: - break; - case SIGHUP: sighup = true; return; default: - return; + syslog(LOG_ERR, "Killed (got signal %d)...", sig); + exit(-1); } - - syslog(LOG_ERR, "Killed..."); - exit(-1); } void common_initialize(void) diff --git a/srsd.c b/srsd.c index 0958bfd..bdd98a8 100644 --- a/srsd.c +++ b/srsd.c @@ -201,13 +201,13 @@ static int main_initialize(void) signal(SIGINT, &common_sighandler); signal(SIGTERM, &common_sighandler); signal(SIGHUP, &common_sighandler); + signal(SIGSEGV, &common_sighandler); syslog(LOG_INFO, "Starting..."); return 0; } static void main_shutdown(void) { - syslog(LOG_INFO, cleanexit ? "Stopping..." : "Unclean exit..."); closelog(); } @@ -332,7 +332,6 @@ int main_loop(srs_t *srs, const char *domain, int port_enc, int port_dec) close(epollfd); error: - cleanexit = true; return exitcode; } @@ -456,5 +455,6 @@ int main(int argc, char *argv[]) fclose(f); f = NULL; } + syslog(LOG_INFO, "Stopping..."); return res; }