lib-signals.c revision 6a25b797af8571c4e463c049ed5cd134f8717982
/* Copyright (c) 2001-2003 Timo Sirainen */
#include "lib.h"
#include "lib-signals.h"
#include <stdio.h>
#include <signal.h>
int lib_signal_kill;
unsigned int lib_signal_hup_count;
unsigned int lib_signal_usr1_count, lib_signal_usr2_count;
static void (*quit_handler) (int);
static void sig_counter(int signo)
{
#ifndef HAVE_SIGACTION
/* some systems may have changed the signal handler to default one */
#endif
switch (signo) {
case SIGHUP:
break;
case SIGUSR1:
break;
case SIGUSR2:
break;
}
}
{
/* if we get killed after this, just die instead of coming back here. */
}
void lib_init_signals(void (*sig_quit_handler) (int))
{
#ifdef HAVE_SIGACTION
#endif
lib_signal_kill = 0;
lib_signal_hup_count = 0;
/* signal() behaviour is a bit inconsistent between systems
after the signal handler has been called. If the signal
isn't ignored, or your handler doesn't kill the program,
sigaction() should be used. */
#ifdef HAVE_SIGACTION
i_fatal("sigemptyset(): %m");
i_fatal("sigaction(): %m");
}
i_fatal("sigaction(): %m");
}
i_fatal("sigaction(): %m");
}
/* we want to just ignore SIGALRM, but to get it to abort syscalls
with EINTR we can't just set it to SIG_IGN. sig_counter handler
is good enough. */
i_fatal("sigaction(): %m");
}
#else
#endif
/* these signals should be called only once, so it's safe to use
signal() */
}