freeradius/freeradius-ignore-SIGTERM-when-firing-stop-and-signal.term.patch
Nikolai Kondrashov d3ba025501 Fix triggers
Resolves: Bug#1110407
Resolves: Bug#1110414
Resolves: Bug#1110186
Resolves: Bug#1109164
2015-01-19 17:52:25 +02:00

60 lines
1.8 KiB
Diff

From b5b92669c32b50b2f96a3ae53d4222d6cb3d1287 Mon Sep 17 00:00:00 2001
From: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com>
Date: Tue, 28 Oct 2014 15:57:56 +0200
Subject: [PATCH 1/1] Ignore SIGTERM when firing stop and signal.term
Move firing "server.stop" and "server.signal.term" triggers beyond
setting SIGTERM action to SIG_IGN in main().
This way handler commands for these triggers don't receive SIGTERM with
the rest of the process group and don't possibly terminate before doing
their work. E.g. snmptrap manages to send the notifications.
---
src/main/process.c | 1 -
src/main/radiusd.c | 10 ++++++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/main/process.c b/src/main/process.c
index 7e1a51e..f427205 100644
--- a/src/main/process.c
+++ b/src/main/process.c
@@ -4536,7 +4536,6 @@ static void handle_signal_self(int flag)
fr_event_loop_exit(el, 1);
} else {
INFO("Signalled to terminate");
- exec_trigger(NULL, NULL, "server.signal.term", true);
fr_event_loop_exit(el, 2);
}
diff --git a/src/main/radiusd.c b/src/main/radiusd.c
index 620d7d4..86c7013 100644
--- a/src/main/radiusd.c
+++ b/src/main/radiusd.c
@@ -592,8 +592,6 @@ int main(int argc, char *argv[])
INFO("Exiting normally");
}
- exec_trigger(NULL, NULL, "server.stop", false);
-
/*
* Ignore the TERM signal: we're
* about to die.
@@ -601,6 +599,14 @@ int main(int argc, char *argv[])
signal(SIGTERM, SIG_IGN);
/*
+ * Fire signal and stop triggers after ignoring SIGTERM, so handlers are
+ * not killed with the rest of the process group, below.
+ */
+ if (status == 2)
+ exec_trigger(NULL, NULL, "server.signal.term", true);
+ exec_trigger(NULL, NULL, "server.stop", false);
+
+ /*
* Send a TERM signal to all
* associated processes
* (including us, which gets
--
2.1.1