From e59e58f958c8e741edbbc9d85ec7289dc88cc31a Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 12 Oct 2013 14:39:47 +0000 Subject: cethcan: ignore SIG{PIPE,HUP,USR1,USR2} SIGPIPE was causing cethcan to exit prematurely. (probably due to a http connection getting closed down.) The other signals are reasonable for a daemon to _not_ cause an exit. --- cethcan/cethcan.h | 1 + cethcan/main.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/cethcan/cethcan.h b/cethcan/cethcan.h index 6763006..ab5edde 100644 --- a/cethcan/cethcan.h +++ b/cethcan/cethcan.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/cethcan/main.c b/cethcan/main.c index a870ca2..961c543 100644 --- a/cethcan/main.c +++ b/cethcan/main.c @@ -8,6 +8,7 @@ int main(int argc, char **argv) const char *cfgfile = "cethcan.json"; json_error_t je; json_t *config; + struct sigaction sa; do { optch = getopt(argc, argv, "c:"); @@ -79,6 +80,13 @@ int main(int argc, char **argv) json_decref(config); + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); + sigaction(SIGHUP, &sa, NULL); + sigaction(SIGUSR1, &sa, NULL); + sigaction(SIGUSR2, &sa, NULL); + event_base_loop(ev_base, 0); return 0; } -- cgit v1.2.1