X-Git-Url: http://the.earth.li/gitweb/?a=blobdiff_plain;f=cleanup.c;h=ecb33220db942b9c0fa1c84dfc8c80149dfcb700;hb=b29df6ee43968324d986717ac10d6e0656925196;hp=9d5e24af48c0211916ab96cc1eb8d6a463bf803f;hpb=1daf67e8e9262de579ba9d23691482529243cce3;p=onak.git diff --git a/cleanup.c b/cleanup.c index 9d5e24a..ecb3322 100644 --- a/cleanup.c +++ b/cleanup.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "cleanup.h" #include "keydb.h" @@ -24,7 +25,7 @@ static bool should_cleanup = false; */ void trytocleanup(void) { - logthing(LOGTHING_NOTICE, "Setting cleanup flag."); + logthing(LOGTHING_INFO, "Setting cleanup flag."); should_cleanup = true; return; @@ -49,7 +50,7 @@ bool cleanup(void) */ void sig_cleanup(int signal) { - logthing(LOGTHING_NOTICE, "Got signal %d.", signal); + logthing(LOGTHING_INFO, "Got signal %d.", signal); trytocleanup(); return; @@ -64,17 +65,13 @@ void sig_cleanup(int signal) */ void catchsignals(void) { - struct sigaction alarmh; + logthing(LOGTHING_INFO, "Catching signals"); - logthing(LOGTHING_NOTICE, "Catching signals"); - - memset(&alarmh, 0, sizeof(alarmh)); - alarmh.sa_handler = sig_cleanup; - sigaction(SIGALRM, &alarmh, NULL); - sigaction(SIGPIPE, &alarmh, NULL); - sigaction(SIGTERM, &alarmh, NULL); - sigaction(SIGINT, &alarmh, NULL); - sigaction(SIGHUP, &alarmh, NULL); + signal(SIGALRM, &sig_cleanup); + signal(SIGPIPE, &sig_cleanup); + signal(SIGTERM, &sig_cleanup); + signal(SIGINT, &sig_cleanup); + signal(SIGHUP, &sig_cleanup); return; }