summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMarc Balmer <mbalmer@cvs.openbsd.org>2006-12-21 15:51:55 +0000
committerMarc Balmer <mbalmer@cvs.openbsd.org>2006-12-21 15:51:55 +0000
commit92cea5bdb88f2b10cf2417e4badf54770d1ef561 (patch)
tree9b38837635f84695576d977d765426e9f11bd1e2 /usr.sbin
parent5408056619abaa262d44882d61df1259095f54f1 (diff)
Let watchdogd use the new watchdog(4) semantics. When the new option -n
(no restore) is specified, the watchdog will not be restored to it's original values when watchdogd terminates. that means, when watchdogd is run with -n and you 'halt' the system, the watchdog hardware will reset it. which is wanted when the machine is remote and the system shuts down unplanned. "looks ok" markus
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/watchdogd/watchdogd.88
-rw-r--r--usr.sbin/watchdogd/watchdogd.c20
2 files changed, 18 insertions, 10 deletions
diff --git a/usr.sbin/watchdogd/watchdogd.8 b/usr.sbin/watchdogd/watchdogd.8
index 34e3360f313..58e878ac350 100644
--- a/usr.sbin/watchdogd/watchdogd.8
+++ b/usr.sbin/watchdogd/watchdogd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: watchdogd.8,v 1.9 2006/08/04 11:08:43 mbalmer Exp $
+.\" $OpenBSD: watchdogd.8,v 1.10 2006/12/21 15:51:54 mbalmer Exp $
.\"
.\" Copyright (c) 2005 Marc Balmer <mbalmer@openbsd.org>
.\"
@@ -22,7 +22,7 @@
.Nd watchdog timer retrigger daemon
.Sh SYNOPSIS
.Nm watchdogd
-.Op Fl dq
+.Op Fl dnq
.Op Fl i Ar interval
.Op Fl p Ar period
.Sh DESCRIPTION
@@ -64,6 +64,10 @@ the value of
.Ar period
(see below)
divided by three is used.
+.It Fl n
+Do not restore the watchdog to its original values once it has been activated.
+With this set, the system will be rebooted by the watchdog even if you enter
+'halt'.
.It Fl p Ar period
Set the hardware timer to expire in
.Ar period
diff --git a/usr.sbin/watchdogd/watchdogd.c b/usr.sbin/watchdogd/watchdogd.c
index 5d364e339ba..ec8c1adeeae 100644
--- a/usr.sbin/watchdogd/watchdogd.c
+++ b/usr.sbin/watchdogd/watchdogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: watchdogd.c,v 1.8 2006/08/04 11:04:55 mbalmer Exp $ */
+/* $OpenBSD: watchdogd.c,v 1.9 2006/12/21 15:51:54 mbalmer Exp $ */
/*
* Copyright (c) 2005 Marc Balmer <mbalmer@openbsd.org>
@@ -37,7 +37,7 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s [-dq] [-i interval] [-p period]\n",
+ fprintf(stderr, "usage: %s [-dnq] [-i interval] [-p period]\n",
__progname);
exit(1);
}
@@ -56,10 +56,10 @@ main(int argc, char *argv[])
size_t len;
u_int interval = 0, period = 30, nperiod;
int ch, trigauto, sauto, speriod;
- int quiet = 0, daemonize = 1, retval = 1;
+ int quiet = 0, daemonize = 1, retval = 1, restore = 1;
int mib[3];
- while ((ch = getopt(argc, argv, "di:p:q")) != -1) {
+ while ((ch = getopt(argc, argv, "di:np:q")) != -1) {
switch (ch) {
case 'd':
daemonize = 0;
@@ -70,6 +70,9 @@ main(int argc, char *argv[])
if (errstr)
errx(1, "interval is %s: %s", errstr, optarg);
break;
+ case 'n':
+ restore = 0;
+ break;
case 'p':
period = (u_int)strtonum(optarg, 2LL, 86400LL, &errstr);
if (errstr)
@@ -144,10 +147,11 @@ main(int argc, char *argv[])
sleep(interval);
}
-restore:
- sysctl(mib, 3, NULL, 0, &speriod, sizeof(speriod));
- mib[2] = KERN_WATCHDOG_AUTO;
- sysctl(mib, 3, NULL, 0, &sauto, sizeof(sauto));
+ if (restore) {
+restore: sysctl(mib, 3, NULL, 0, &speriod, sizeof(speriod));
+ mib[2] = KERN_WATCHDOG_AUTO;
+ sysctl(mib, 3, NULL, 0, &sauto, sizeof(sauto));
+ }
return (retval);
}