improved logging for piler-smtp.c

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2018-03-13 14:50:49 +01:00
parent e5262ff935
commit 0e116cfd6e
3 changed files with 11 additions and 31 deletions

View File

@ -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);

View File

@ -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> Config file to use if not the default\n");

View File

@ -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();