imapfilter/src/signal.c
Lefteris Chatzimparmpas 4fe1a3d649 Change file and directory structure
Move the source code to the src dir, the man pages to the doc dir, and
the example configuration files to the samples dir, and update all
relevant files to reflect the changes.
2011-03-06 13:34:44 +01:00

46 lines
623 B
C

#include <signal.h>
#include "imapfilter.h"
void signal_handler(int sig);
/*
* Catch signals that cause program's termination.
*/
void
catch_signals(void)
{
signal(SIGINT, signal_handler);
signal(SIGQUIT, signal_handler);
signal(SIGTERM, signal_handler);
}
/*
* Release signals and reset them to default action.
*/
void
release_signals(void)
{
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
}
/*
* Signal handler for signals that cause termination of program.
*/
void
signal_handler(int sig)
{
release_signals();
fatal(ERROR_SIGNAL, "killed by signal %d\n", sig);
}