signalHandling.c 486 Bytes
#include <signal.h>     /* for signal() and signal names */

volatile int doShutdown;

void terminate(int signum)
{
    signal(signum, SIG_IGN);
    /*
     * @TODO do logging here
     */
    doShutdown = 1;
}

void init_signals(void)
{
    signal(SIGTERM, terminate);
    signal(SIGHUP, SIG_IGN);
    signal(SIGINT, terminate);
    signal(SIGQUIT, terminate);
    signal(SIGABRT, terminate);
    signal(SIGALRM, SIG_IGN);
    signal(SIGURG, SIG_IGN);

    signal(SIGPIPE, SIG_IGN);
}