|
|
45d60a |
diff --git a/omapip/isclib.c b/omapip/isclib.c
|
|
|
45d60a |
index b3d336d..b252fb6 100644
|
|
|
45d60a |
--- a/omapip/isclib.c
|
|
|
45d60a |
+++ b/omapip/isclib.c
|
|
|
45d60a |
@@ -28,6 +28,7 @@
|
|
|
45d60a |
#include "dhcpd.h"
|
|
|
45d60a |
|
|
|
45d60a |
#include <sys/time.h>
|
|
|
45d60a |
+#include <signal.h>
|
|
|
45d60a |
|
|
|
45d60a |
dhcp_context_t dhcp_gbl_ctx;
|
|
|
45d60a |
|
|
|
45d60a |
@@ -67,6 +67,21 @@ isclib_cleanup(void)
|
|
|
45d60a |
return;
|
|
|
45d60a |
}
|
|
|
45d60a |
|
|
|
45d60a |
+/* Installs a handler for a signal using sigaction */
|
|
|
45d60a |
+static void
|
|
|
45d60a |
+handle_signal(int sig, void (*handler)(int)) {
|
|
|
45d60a |
+ struct sigaction sa;
|
|
|
45d60a |
+
|
|
|
45d60a |
+ memset(&sa, 0, sizeof(sa));
|
|
|
45d60a |
+ sa.sa_handler = handler;
|
|
|
45d60a |
+ sigfillset(&sa.sa_mask);
|
|
|
45d60a |
+ if (sigaction(sig, &sa, NULL) != 0) {
|
|
|
45d60a |
+ log_debug("handle_signal() failed for signal %d error: %s",
|
|
|
45d60a |
+ sig, strerror(errno));
|
|
|
45d60a |
+ }
|
|
|
45d60a |
+}
|
|
|
45d60a |
+
|
|
|
45d60a |
+
|
|
|
45d60a |
isc_result_t
|
|
|
45d60a |
dhcp_context_create(void) {
|
|
|
45d60a |
isc_result_t result;
|
|
|
45d60a |
@@ -102,11 +117,6 @@ dhcp_context_create(void) {
|
|
|
45d60a |
if (result != ISC_R_SUCCESS)
|
|
|
45d60a |
goto cleanup;
|
|
|
45d60a |
|
|
|
45d60a |
- result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
|
|
|
45d60a |
- if (result != ISC_R_SUCCESS)
|
|
|
45d60a |
- return (result);
|
|
|
45d60a |
- dhcp_gbl_ctx.actx_started = ISC_TRUE;
|
|
|
45d60a |
-
|
|
|
45d60a |
result = isc_taskmgr_createinctx(dhcp_gbl_ctx.mctx,
|
|
|
45d60a |
dhcp_gbl_ctx.actx,
|
|
|
45d60a |
1, 0,
|
|
|
45d60a |
@@ -130,6 +140,21 @@ dhcp_context_create(void) {
|
|
|
45d60a |
if (result != ISC_R_SUCCESS)
|
|
|
45d60a |
goto cleanup;
|
|
|
45d60a |
|
|
|
45d60a |
+ result = isc_app_ctxstart(dhcp_gbl_ctx.actx);
|
|
|
45d60a |
+ if (result != ISC_R_SUCCESS)
|
|
|
45d60a |
+ return (result);
|
|
|
45d60a |
+ dhcp_gbl_ctx.actx_started = ISC_TRUE;
|
|
|
45d60a |
+
|
|
|
45d60a |
+ /* Not all OSs support suppressing SIGPIPE through socket
|
|
|
45d60a |
+ * options, so set the sigal action to be ignore. This allows
|
|
|
45d60a |
+ * broken connections to fail gracefully with EPIPE on writes */
|
|
|
45d60a |
+ handle_signal(SIGPIPE, SIG_IGN);
|
|
|
45d60a |
+
|
|
|
45d60a |
+ /* Reset handlers installed by isc_app_ctxstart()
|
|
|
45d60a |
+ * to default for control-c and kill */
|
|
|
45d60a |
+ handle_signal(SIGINT, SIG_DFL);
|
|
|
45d60a |
+ handle_signal(SIGTERM, SIG_DFL);
|
|
|
45d60a |
+
|
|
|
45d60a |
#if !defined (NSUPDATE)
|
|
|
45d60a |
/* The dst library is inited as part of dns_lib_init, we don't
|
|
|
45d60a |
* need it if NSUPDATE is enabled */
|