2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 06:15:55 +00:00
[32692] Signal handlers added: sigint (ctrl-c) and sigterm (default kill)
This commit is contained in:
Shawn Routhier
2013-10-30 13:52:36 -07:00
parent 58cb5d861d
commit 47e8308dea
8 changed files with 111 additions and 19 deletions

View File

@@ -42,11 +42,11 @@ static const char url [] =
#include "dhcpd.h"
#include <omapip/omapip_p.h>
#include <syslog.h>
#include <signal.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
#if defined (PARANOIA)
# include <sys/types.h>
@@ -780,10 +780,20 @@ main(int argc, char **argv) {
omapi_set_int_value ((omapi_object_t *)dhcp_control_object,
(omapi_object_t *)0, "state", server_running);
/* Receive packets and dispatch them... */
/* install signal handlers */
signal(SIGINT, dhcp_signal_handler); /* control-c */
signal(SIGTERM, dhcp_signal_handler); /* kill */
/*
* Receive packets and dispatch them...
* dispatch() will return only when we are shutting down.
*/
dispatch ();
/* Not reached */
log_info("Shutting down.");
dhcp_set_control_state(server_shutdown/*ignored*/, server_shutdown);
/* Let's return status code */
return 0;
}
#endif /* !UNIT_TEST */