diff --git a/src/random.c b/src/random.c index be0451c1e..a2725c8ac 100644 --- a/src/random.c +++ b/src/random.c @@ -57,10 +57,7 @@ int main(int argc, char *argv[]) }; sigemptyset(&sa_tick.sa_mask); - - if (sigaction(SIG, &sa_tick, NULL)) { - error("Failed sigaction(): %s", strerror(errno)); - } + sigaction(SIG, &sa_tick, NULL); /* Setup timer */ timer_t t; diff --git a/src/receive.c b/src/receive.c index f8c96060a..3a5c1c431 100644 --- a/src/receive.c +++ b/src/receive.c @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) }; sigemptyset(&sa_quit.sa_mask); + sigaction(SIGTERM, &sa_quit, NULL); sigaction(SIGINT, &sa_quit, NULL); /* Resolve address */ diff --git a/src/send.c b/src/send.c index ad4a1e233..4d05379d6 100644 --- a/src/send.c +++ b/src/send.c @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) }; sigemptyset(&sa_quit.sa_mask); + sigaction(SIGTERM, &sa_quit, NULL); sigaction(SIGINT, &sa_quit, NULL); /* Resolve address */ diff --git a/src/server.c b/src/server.c index f3c57b594..b9673d57b 100644 --- a/src/server.c +++ b/src/server.c @@ -82,8 +82,19 @@ int main(int argc, char *argv[]) path_start(&config.paths[i]); } - signal(SIGINT, quit); - pause(); + /* Start and connect all paths/nodes */ + /* Setup signals */ + struct sigaction sa_quit = { + .sa_flags = SA_SIGINFO, + .sa_sigaction = quit + }; + + sigemptyset(&sa_quit.sa_mask); + sigaction(SIGTERM, &sa_quit, NULL); + sigaction(SIGINT, &sa_quit, NULL); + + /* Main thread is sleeping */ + while (1) pause(); quit(); diff --git a/src/test.c b/src/test.c index 4bf03afac..8e3b8add5 100644 --- a/src/test.c +++ b/src/test.c @@ -45,6 +45,7 @@ int main(int argc, char *argv[]) }; sigemptyset(&sa_quit.sa_mask); + sigaction(SIGTERM, &sa_quit, NULL); sigaction(SIGINT, &sa_quit, NULL); /* Resolve address */