summaryrefslogtreecommitdiff
path: root/cethcan
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2013-10-12 14:39:47 +0000
committerroot <root@beaglebone.local.sublab.org>2014-04-27 17:57:39 +0000
commite59e58f958c8e741edbbc9d85ec7289dc88cc31a (patch)
tree4ff41d71937bd631f631b35773f8cde0b873ddbe /cethcan
parent2c29a04e745eba7c03d7251c697bfc519e0c0f9d (diff)
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.
Diffstat (limited to 'cethcan')
-rw-r--r--cethcan/cethcan.h1
-rw-r--r--cethcan/main.c8
2 files changed, 9 insertions, 0 deletions
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 <sys/uio.h>
#include <fcntl.h>
#include <time.h>
+#include <signal.h>
#include <assert.h>
#include <event2/event.h>
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;
}