X-Git-Url: https://the.earth.li/gitweb/?p=onak.git;a=blobdiff_plain;f=cleanup.c;h=3fe219fb4c02127a928335a969b1e33745ebe956;hp=9d5e24af48c0211916ab96cc1eb8d6a463bf803f;hb=3da81770b841f841c5145f91a9ccedc296e13f4b;hpb=1daf67e8e9262de579ba9d23691482529243cce3 diff --git a/cleanup.c b/cleanup.c index 9d5e24a..3fe219f 100644 --- a/cleanup.c +++ b/cleanup.c @@ -1,17 +1,25 @@ /* * cleanup.c - Cleanup and shutdown framework. * - * Jonathan McDowell + * Copyright 2004 Jonathan McDowell * - * Copyright 2004 Project Purple + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ #include #include -#include #include "cleanup.h" -#include "keydb.h" #include "log.h" static bool should_cleanup = false; @@ -24,7 +32,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 +57,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 +72,13 @@ void sig_cleanup(int signal) */ void catchsignals(void) { - struct sigaction alarmh; - - logthing(LOGTHING_NOTICE, "Catching signals"); + logthing(LOGTHING_INFO, "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; }