summaryrefslogtreecommitdiff
path: root/sys/kern/kern_watchdog.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/kern_watchdog.c')
-rw-r--r--sys/kern/kern_watchdog.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/kern_watchdog.c b/sys/kern/kern_watchdog.c
index b58d1fec115..cb48d10b8dc 100644
--- a/sys/kern/kern_watchdog.c
+++ b/sys/kern/kern_watchdog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_watchdog.c,v 1.6 2006/09/19 21:43:13 mk Exp $ */
+/* $OpenBSD: kern_watchdog.c,v 1.7 2006/12/21 12:47:57 mbalmer Exp $ */
/*
* Copyright (c) 2003 Markus Friedl. All rights reserved.
@@ -35,6 +35,7 @@ int (*wdog_ctl_cb)(void *, int) = NULL;
void *wdog_ctl_cb_arg = NULL;
int wdog_period = 0;
int wdog_auto = 1;
+void *wdog_cookie;
struct timeout wdog_timeout;
void
@@ -46,7 +47,7 @@ wdog_register(void *cb_arg, int (*cb)(void *, int))
wdog_ctl_cb = cb;
wdog_ctl_cb_arg = cb_arg;
timeout_set(&wdog_timeout, wdog_tickle, NULL);
- shutdownhook_establish(wdog_shutdown, NULL);
+ wdog_cookie = shutdownhook_establish(wdog_shutdown, NULL);
}
void
@@ -94,6 +95,13 @@ sysctl_wdog(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
error = sysctl_int(oldp, oldlenp, newp, newlen, &wdog_auto);
if (error)
return (error);
+ if (wdog_auto && wdog_cookie == NULL)
+ wdog_cookie = shutdownhook_establish(wdog_shutdown,
+ NULL);
+ else if (!wdog_auto && wdog_cookie) {
+ shutdownhook_disestablish(wdog_cookie);
+ wdog_cookie = NULL;
+ }
break;
default:
return (EINVAL);