summaryrefslogtreecommitdiff
path: root/omapip/isclib.c
diff options
context:
space:
mode:
authorShawn Routhier <sar@isc.org>2013-10-30 13:52:36 -0700
committerShawn Routhier <sar@isc.org>2013-10-30 13:52:36 -0700
commit47e8308dea6ee44ce19edf4fdf3331fa41a986f7 (patch)
treec2801fff3fff0639b504de72675ea62b0d1cab65 /omapip/isclib.c
parent58cb5d861d6f412475722381723dc788c314c39f (diff)
downloadisc-dhcp-47e8308dea6ee44ce19edf4fdf3331fa41a986f7.tar.gz
[master]
[32692] Signal handlers added: sigint (ctrl-c) and sigterm (default kill)
Diffstat (limited to 'omapip/isclib.c')
-rw-r--r--omapip/isclib.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/omapip/isclib.c b/omapip/isclib.c
index 1534dde5..5dcb12c0 100644
--- a/omapip/isclib.c
+++ b/omapip/isclib.c
@@ -1,5 +1,5 @@
/*
- * Copyright(c) 2009-2010 by Internet Systems Consortium, Inc.("ISC")
+ * Copyright(c) 2009-2010,2013 by Internet Systems Consortium, Inc.("ISC")
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -28,6 +28,7 @@
#include "dhcpd.h"
#include <sys/time.h>
+#include <signal.h>
dhcp_context_t dhcp_gbl_ctx;
@@ -217,3 +218,20 @@ isclib_make_dst_key(char *inname,
&b, dhcp_gbl_ctx.mctx, dstkey));
}
+/**
+ * signal handler that initiates server shutdown
+ *
+ * @param signal signal code that we received
+ */
+void dhcp_signal_handler(int signal) {
+ isc_appctx_t *ctx = dhcp_gbl_ctx.actx;
+ if (ctx && ctx->methods && ctx->methods->ctxshutdown) {
+ /*
+ * Let's not use standard log facilities here. They may not be
+ * signal safe, e.g. we could get the signal in the middle of
+ * another log call
+ */
+ printf("Received signal %d, initiating shutdown.\n", signal);
+ ctx->methods->ctxshutdown(ctx);
+ }
+}