
Путь: Toys/Other, команды версии: Ver.4 Ver.9 watchdog Комментарии в файле watchdog.c :
Исходный текст в файле watchdog.c #define FOR_watchdog
#include "toys.h"
#include "linux/watchdog.h"
GLOBALS(
long T, t;
int fd;
)
static void safe_shutdown(int ignored)
{
write(TT.fd, "V", 1);
close(TT.fd);
error_exit("safely exited watchdog.");
}
void watchdog_main(void)
{
if (!FLAG(F)) xvdaemon();
xsignal(SIGTERM, safe_shutdown);
xsignal(SIGINT, safe_shutdown);
xioctl(TT.fd = xopen(*toys.optargs, O_WRONLY), WDIOC_SETTIMEOUT, &TT.T);
// Now that we've got the watchdog device open, kick it periodically.
for (;;) {
write(TT.fd, "", 1);
sleep(TT.t);
}
} |
![]() |