gluon-radv-filterd: Call cleanup when stopping daemon

Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
Sven Eckelmann 2017-12-20 14:02:08 +01:00 committed by Jan-Philipp Litza
parent 2d3614c1a9
commit 2394ad0c07
No known key found for this signature in database
GPG Key ID: 1FB658053CE27196

View File

@ -115,6 +115,7 @@ static struct global {
uint16_t max_tq;
uint16_t hysteresis_thresh;
struct router *best_router;
volatile sig_atomic_t stop_daemon;
} G = {
.mesh_iface = "bat0",
};
@ -726,6 +727,11 @@ static void update_ebtables(void) {
error_message(0, 0, "warning: adding new rule to ebtables chain %s failed", G.chain);
}
static void sighandler(int sig __attribute__((unused)))
{
G.stop_daemon = 1;
}
int main(int argc, char *argv[]) {
int retval;
fd_set rfds;
@ -746,7 +752,11 @@ int main(int argc, char *argv[]) {
if (G.chain == NULL)
usage("No chain set!");
while (1) {
G.stop_daemon = 0;
signal(SIGINT, sighandler);
signal(SIGTERM, sighandler);
while (!G.stop_daemon) {
FD_ZERO(&rfds);
FD_SET(G.sock, &rfds);