#include <signal.h>
static void
sigterm(int sig){
/*int save_errno = errno;*/
signal(sig, SIG_IGN); /* Ignore this signal while we are quitting */
}
int init_daemon()
{
struct sigaction sa;
/* set signal handler */
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = sigterm;
if (sigaction(SIGTERM, &sa, NULL))
{
CWLog("Failed to set %s handler. EXITING", "SIGTERM");
return 1;
}
if (sigaction(SIGINT, &sa, NULL))
{
CWLog("Failed to set %s handler. EXITING", "SIGINT");
return 1;
}
if(signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
CWLog("Failed to ignore SIGPIPE signals");
}
}