mirror of
https://gitlab.labs.nic.cz/labs/bird.git
synced 2024-05-11 16:54:54 +00:00
Perform gracious shutdown upon receipt of SIGTERM. Finally we can
test the whole protocol shutdown code... :)
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#include "unix.h"
|
||||
#include "krt.h"
|
||||
|
||||
int shutting_down;
|
||||
|
||||
/*
|
||||
* Debugging
|
||||
*/
|
||||
@@ -82,6 +84,24 @@ async_config(void)
|
||||
debug("Asynchronous reconfigurations are not supported in demo version\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Shutdown
|
||||
*/
|
||||
|
||||
void
|
||||
async_shutdown(void)
|
||||
{
|
||||
debug("Shutting down...\n");
|
||||
shutting_down = 1;
|
||||
protos_shutdown();
|
||||
}
|
||||
|
||||
void
|
||||
protos_shutdown_notify(void)
|
||||
{
|
||||
die("System shutdown completed");
|
||||
}
|
||||
|
||||
/*
|
||||
* Signals
|
||||
*/
|
||||
@@ -100,6 +120,13 @@ handle_sigusr(int sig)
|
||||
async_dump_flag = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_sigterm(int sig)
|
||||
{
|
||||
debug("Caught SIGTERM...\n");
|
||||
async_shutdown_flag = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
signal_init(void)
|
||||
{
|
||||
@@ -112,6 +139,9 @@ signal_init(void)
|
||||
sa.sa_handler = handle_sighup;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigaction(SIGHUP, &sa, NULL);
|
||||
sa.sa_handler = handle_sigterm;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigaction(SIGTERM, &sa, NULL);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user