]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - share/man/man4/watchdog.4
MFC r362623:
[FreeBSD/stable/8.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 June 25, 2003
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 The device
42 .Pa /dev/fido
43 responds to a single
44 .Xr ioctl 2
45 call,
46 .Dv WDIOCPATPAT .
47 It takes a single argument which represents a timeout value specified as a
48 power of two nanoseconds, or-ed with a flag selecting active or passive control
49 of the watchdog.
50 .Pp
51 .Dv WD_ACTIVE
52 indicates that the
53 .Nm
54 will be kept from timing out from userland, for instance by the
55 .Xr watchdogd 8
56 daemon.
57 .Dv WD_PASSIVE
58 indicates that the
59 .Nm
60 will be kept from timing out from the kernel.
61 .Pp
62 The
63 .Xr ioctl 2
64 call will return success if just one of the available
65 .Xr watchdog 9
66 implementations supports setting the timeout to the specified timeout. This
67 means that at least one watchdog is armed. If the call fails, for instance if
68 none of
69 .Xr watchdog 9
70 implementations support the timeout length, all watchdogs are disabled and must
71 be explicitly re-enabled.
72 .Pp
73 To disable the watchdogs pass
74 .Dv WD_TO_NEVER .
75 If disarming the watchdog(s) failed an error is returned. The watchdog might
76 still be armed!
77 .Sh RETURN VALUES
78 The ioctl returns zero on success and non-zero on failure.
79 .Bl -tag -width Er
80 .It Bq Er EOPNOTSUPP
81 No watchdog present in the kernel (timeout value other than 0).
82 .It Bq Er EOPNOTSUPP
83 Watchdog could not be disabled (timeout value of 0).
84 .It Bq Er EINVALID
85 Invalid flag combination passed.
86 .It Bq Er EINVALID
87 None of the watchdogs supports the requested timeout value.
88 .El
89 .Sh EXAMPLES
90 .Bd -literal -offset indent
91 #include <paths.h>
92 #include <sys/watchdog.h>
93
94 #define WDPATH  "/dev/" _PATH_WATCHDOG
95 int wdfd = -1;
96
97 static void
98 wd_init(void) 
99 {
100         wdfd = open(WDPATH, O_RDWR);
101         if (wdfd == -1)
102                 err(1, WDPATH);
103 }
104 static void
105 wd_reset(u_int timeout)
106 {
107         if (ioctl(wdfd, WDIOCPATPAT, &timeout) == -1)
108                 err(1, "WDIOCPATPAT");
109 }
110
111 /* in main() */
112 wd_init();
113 wd_reset(WD_ACTIVE|WD_TO_8SEC);
114 /* potential freeze point */
115 wd_reset(WD_TO_NEVER);
116 .Ed
117 .Pp
118 Enables a watchdog to recover from a potentially freezing piece of code.
119 .Pp
120 .Bd -literal -offset indent
121 options SW_WATCHDOG
122 .Ed
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 BUGS
135 The
136 .Dv WD_PASSIVE
137 option has not yet been implemented.
138 .Sh AUTHORS
139 .An -nosplit
140 The
141 .Nm
142 facility was written by
143 .An Poul-Henning Kamp Aq phk@FreeBSD.org .
144 The software watchdog code and this manual page were written by
145 .An Sean Kelly Aq smkelly@FreeBSD.org .
146 Some contributions were made by
147 .An Jeff Roberson Aq jeff@FreeBSD.org .