]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - share/man/man4/watchdog.4
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / share / man / man4 / watchdog.4
1 .\" Copyright (c) 2004 Poul-Henning Kamp <phk@FreeBSD.org>
2 .\" Copyright (c) 2003, 2004 Sean M. Kelly <smkelly@FreeBSD.org>
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd December 21, 2009
29 .Dt WATCHDOG 4
30 .Os
31 .Sh NAME
32 .Nm watchdog
33 .Nd "hardware and software watchdog"
34 .Sh SYNOPSIS
35 .In sys/watchdog.h
36 .Sh DESCRIPTION
37 The
38 .Nm
39 facility is used for controlling hardware and software watchdogs.
40 .Pp
41 .Pa /dev/fido
42 responds to a single
43 .Xr ioctl 2
44 call,
45 .Dv WDIOCPATPAT .
46 It takes a single argument which represents a timeout value specified as a
47 power of two nanoseconds, or-ed with a flag selecting active or passive control
48 of the watchdog.
49 .Pp
50 .Dv WD_ACTIVE
51 indicates that the
52 .Nm
53 will be kept from timing out from userland, for instance by the
54 .Xr watchdogd 8
55 daemon.
56 .Dv WD_PASSIVE
57 indicates that the
58 .Nm
59 will be kept from timing out from the kernel.
60 .Pp
61 The
62 .Xr ioctl 2
63 call will return success if just one of the available
64 .Xr watchdog 9
65 implementations supports setting the timeout to the specified timeout.
66 This
67 means that at least one watchdog is armed.
68 If the call fails, for instance if
69 none of
70 .Xr watchdog 9
71 implementations support the timeout length, all watchdogs are disabled and must
72 be explicitly re-enabled.
73 .Pp
74 To disable the watchdogs pass
75 .Dv WD_TO_NEVER .
76 If disarming the watchdog(s) failed an error is returned.
77 The watchdog might
78 still be armed!
79 .Sh RETURN VALUES
80 The ioctl returns zero on success and non-zero on failure.
81 .Bl -tag -width Er
82 .It Bq Er EOPNOTSUPP
83 No watchdog present in the kernel or
84 none of the watchdogs supports the requested timeout value
85 (timeout value other than 0).
86 .It Bq Er EOPNOTSUPP
87 Watchdog could not be disabled (timeout value of 0).
88 .It Bq Er EINVAL
89 Invalid flag combination passed.
90 .El
91 .Sh EXAMPLES
92 .Bd -literal -offset indent
93 #include <paths.h>
94 #include <sys/watchdog.h>
95
96 #define WDPATH  "/dev/" _PATH_WATCHDOG
97 int wdfd = -1;
98
99 static void
100 wd_init(void)
101 {
102         wdfd = open(WDPATH, O_RDWR);
103         if (wdfd == -1)
104                 err(1, WDPATH);
105 }
106 static void
107 wd_reset(u_int timeout)
108 {
109         if (ioctl(wdfd, WDIOCPATPAT, &timeout) == -1)
110                 err(1, "WDIOCPATPAT");
111 }
112
113 /* in main() */
114 wd_init();
115 wd_reset(WD_ACTIVE|WD_TO_8SEC);
116 /* potential freeze point */
117 wd_reset(WD_TO_NEVER);
118 .Ed
119 .Pp
120 Enables a watchdog to recover from a potentially freezing piece of code.
121 .Pp
122 .Dl "options SW_WATCHDOG"
123 .Pp
124 in your kernel config adds a software watchdog in the kernel, dropping to KDB
125 or panic-ing when firing.
126 .Sh SEE ALSO
127 .Xr watchdogd 8 ,
128 .Xr watchdog 9
129 .Sh HISTORY
130 The
131 .Nm
132 code first appeared in
133 .Fx 5.1 .
134 .Sh AUTHORS
135 .An -nosplit
136 The
137 .Nm
138 facility was written by
139 .An Poul-Henning Kamp Aq phk@FreeBSD.org .
140 The software watchdog code and this manual page were written by
141 .An Sean Kelly Aq smkelly@FreeBSD.org .
142 Some contributions were made by
143 .An Jeff Roberson Aq jeff@FreeBSD.org .
144 .Sh BUGS
145 The
146 .Dv WD_PASSIVE
147 option has not yet been implemented.