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