Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-serial
[powerpc.git] / Documentation / watchdog / watchdog-api.txt
index 7dc2c1c..958ff3d 100644 (file)
@@ -34,22 +34,7 @@ activates as soon as /dev/watchdog is opened and will reboot unless
 the watchdog is pinged within a certain time, this time is called the
 timeout or margin.  The simplest way to ping the watchdog is to write
 some data to the device.  So a very simple watchdog daemon would look
-like this:
-
-#include <stdlib.h>
-#include <fcntl.h>
-
-int main(int argc, const char *argv[]) {
-       int fd=open("/dev/watchdog",O_WRONLY);
-       if (fd==-1) {
-               perror("watchdog");
-               exit(1);
-       }
-       while(1) {
-               write(fd, "\0", 1);
-               sleep(10);
-       }
-}
+like this source file:  see Documentation/watchdog/src/watchdog-simple.c
 
 A more advanced driver could for example check that a HTTP server is
 still responding before doing the write call to ping the watchdog.
@@ -134,6 +119,15 @@ There is also a get function for getting the pretimeout:
 
 Not all watchdog drivers will support a pretimeout.
 
+Get the number of seconds before reboot:
+
+Some watchdog drivers have the ability to report the remaining time
+before the system will reboot. The WDIOC_GETTIMELEFT is the ioctl
+that returns the number of seconds before reboot.
+
+    ioctl(fd, WDIOC_GETTIMELEFT, &timeleft);
+    printf("The timeout was is %d seconds\n", timeleft);
+
 Environmental monitoring:
 
 All watchdog drivers are required return more information about the system,