FreeBSD Manual Pages
WATCHDOG(4) Kernel Interfaces Manual WATCHDOG(4) NAME watchdog -- hardware and software watchdog SYNOPSIS #include <sys/watchdog.h> DESCRIPTION The watchdog facility is used for controlling hardware and software watch- dogs. The device /dev/fido supports several optional ioctl(2) calls for configu- ration, and responds to a single operational ioctl(2) call, WDIOCPATPAT. It takes a single argument which represents a timeout value specified as a power of two nanoseconds, or-ed with a flag selecting active or passive control of the watchdog. WD_ACTIVE indicates that the watchdog will be kept from timing out from userland, for instance by the watchdogd(8) daemon. WD_PASSIVE indicates that the watchdog will be kept from timing out from the kernel. The WDIOCPATPAT ioctl(2) call will return success if just one of the avail- able watchdog(9) implementations supports setting the timeout to the speci- fied timeout. This means that at least one watchdog is armed. By default, this will be a hardware watchdog if one is present, but if no hardware watchdog is able to process the request, a default software watchdog is en- abled. If the call fails, for instance if none of watchdog(9) implementa- tions support the timeout length, all watchdogs are disabled and must be explicitly re-enabled. To disable the watchdogs pass WD_TO_NEVER. If disarming the watchdog(s) failed an error is returned. The watchdog might still be armed! The optional configuration ioctl(2) commands are listed here, along with the type of the parameter used. Examples of their use can be found in watchdogd(8). WDIOC_SETTIMEOUT int set/reset the timer WDIOC_GETTIMEOUT int get total timeout WDIOC_GETTIMELEFT int get time left WDIOC_GETPRETIMEOUT int get the pre-timeout WDIOC_SETPRETIMEOUT int set the pre-timeout WDIOC_SETPRETIMEOUTACT int Set the action when a pre-timeout occurs (see WD_SOFT_* below). WDIOC_SETSOFT int Use an internal software watchdog instead of hardware. There is also an external soft- ware watchdog, which is used by default if no hardware watchdog was attached. WDIOC_SETSOFTTIMEOUTACT int Set the action when a soft timeout occurs. The actions that may be specified for the pre-timeout or the internal soft- ware watchdog are listed here. Multiple actions can be specified by ORing values together. WD_SOFT_PANIC panic WD_SOFT_DDB enter debugger WD_SOFT_LOG log(9) WD_SOFT_PRINT printf(9) RETURN VALUES The WDIOCPATPAT ioctl(2) returns zero on success and non-zero on failure. [EOPNOTSUPP] No watchdog present in the kernel or none of the watch- dogs supports the requested timeout value (timeout value other than 0). [EOPNOTSUPP] Watchdog could not be disabled (timeout value of 0). [EINVAL] Invalid flag combination passed. The configuration ioctl(2) operations return zero on success and non-zero on failure. EXAMPLES #include <paths.h> #include <sys/watchdog.h> #define WDPATH "/dev/" _PATH_WATCHDOG int wdfd = -1; static void wd_init(void) { wdfd = open(WDPATH, O_RDWR); if (wdfd == -1) err(1, WDPATH); } static void wd_reset(u_int timeout) { if (ioctl(wdfd, WDIOCPATPAT, &timeout) == -1) err(1, "WDIOCPATPAT"); } /* in main() */ wd_init(); wd_reset(WD_ACTIVE|WD_TO_8SEC); /* potential freeze point */ wd_reset(WD_TO_NEVER); Enables a watchdog to recover from a potentially freezing piece of code. options SW_WATCHDOG in your kernel config forces a software watchdog in the kernel to be con- figured even if a hardware watchdog is configured, dropping to KDB or pan- icking when firing, depending on the KDB and KDB_UNATTENDED kernel configu- ration options. SEE ALSO watchdogd(8), watchdog(9) HISTORY The watchdog code first appeared in FreeBSD 5.1. AUTHORS The watchdog facility was written by Poul-Henning Kamp <phk@FreeBSD.org>. The software watchdog code and this manual page were written by Sean Kelly <smkelly@FreeBSD.org>. Some contributions were made by Jeff Roberson <jeff@FreeBSD.org>. BUGS The WD_PASSIVE option has not yet been implemented. FreeBSD ports 15.1 January 2, 2018 WATCHDOG(4)
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | EXAMPLES | SEE ALSO | HISTORY | AUTHORS | BUGS
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=watchdog&sektion=4&manpath=FreeBSD+15.1-RELEASE+and+Ports>
