From 0e116cfd6e121f3f1f1272da5386b16df87876b6 Mon Sep 17 00:00:00 2001 From: Janos SUTO Date: Tue, 13 Mar 2018 14:50:49 +0100 Subject: [PATCH] improved logging for piler-smtp.c Signed-off-by: Janos SUTO --- src/piler-smtp.c | 38 ++++++++------------------------------ src/piler.c | 3 +++ src/piler.h | 1 - 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/src/piler-smtp.c b/src/piler-smtp.c index 370edb9a..edb68758 100644 --- a/src/piler-smtp.c +++ b/src/piler-smtp.c @@ -52,9 +52,11 @@ void usage(){ } -void p_clean_exit(){ +void p_clean_exit(int sig){ int i; + syslog(LOG_PRIORITY, "got signal: %d, %s", sig, strsignal(sig)); + if(listenerfd != -1) close(listenerfd); if(sessions){ @@ -75,33 +77,9 @@ void p_clean_exit(){ } -void p_term_exit(){ - syslog(LOG_PRIORITY, "got signal: SIGTERM"); - p_clean_exit(); -} - - -void p_kill_exit(){ - syslog(LOG_PRIORITY, "got signal: SIGKILL"); - p_clean_exit(); -} - - -void p_stop_exit() { - syslog(LOG_PRIORITY, "got signal: SIGSTOP"); - p_clean_exit(); -} - - -void p_segv_exit(){ - syslog(LOG_PRIORITY, "got signal: SIGSEGV"); - p_clean_exit(); -} - - void fatal(char *s){ syslog(LOG_PRIORITY, "%s", s); - p_clean_exit(); + p_clean_exit(0); } @@ -211,11 +189,11 @@ int main(int argc, char **argv){ } set_signal_handler(SIGINT, p_clean_exit); - set_signal_handler(SIGTERM, p_term_exit); + set_signal_handler(SIGTERM, p_clean_exit); - set_signal_handler(SIGKILL, p_kill_exit); - set_signal_handler(SIGSEGV, p_segv_exit); - set_signal_handler(SIGSTOP, p_stop_exit); + set_signal_handler(SIGKILL, p_clean_exit); + set_signal_handler(SIGSEGV, p_clean_exit); + set_signal_handler(SIGSTOP, p_clean_exit); set_signal_handler(SIGALRM, check_for_client_timeout); set_signal_handler(SIGHUP, initialise_configuration); diff --git a/src/piler.c b/src/piler.c index 16c59dc6..04b73018 100644 --- a/src/piler.c +++ b/src/piler.c @@ -41,6 +41,9 @@ struct passwd *pwd; struct child children[MAXCHILDREN]; +void p_clean_exit(); + + void usage(){ printf("\nusage: piler\n\n"); printf(" -c Config file to use if not the default\n"); diff --git a/src/piler.h b/src/piler.h index 9b1367c6..d12a08e2 100644 --- a/src/piler.h +++ b/src/piler.h @@ -80,7 +80,6 @@ void child_main(struct child *ptr); pid_t child_make(struct child *ptr); int search_slot_by_pid(pid_t pid); void kill_children(int sig); -void p_clean_exit(); void fatal(char *s); void initialise_configuration();