|
@@ -23,6 +23,7 @@ static void keep_alive(void)
|
|
|
{
|
|
{
|
|
|
int dummy;
|
|
int dummy;
|
|
|
|
|
|
|
|
|
|
+ printf(".");
|
|
|
ioctl(fd, WDIOC_KEEPALIVE, &dummy);
|
|
ioctl(fd, WDIOC_KEEPALIVE, &dummy);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -34,7 +35,7 @@ static void keep_alive(void)
|
|
|
static void term(int sig)
|
|
static void term(int sig)
|
|
|
{
|
|
{
|
|
|
close(fd);
|
|
close(fd);
|
|
|
- fprintf(stderr, "Stopping watchdog ticks...\n");
|
|
|
|
|
|
|
+ printf("\nStopping watchdog ticks...\n");
|
|
|
exit(0);
|
|
exit(0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -43,11 +44,12 @@ int main(int argc, char *argv[])
|
|
|
int flags;
|
|
int flags;
|
|
|
unsigned int ping_rate = 1;
|
|
unsigned int ping_rate = 1;
|
|
|
|
|
|
|
|
|
|
+ setbuf(stdout, NULL);
|
|
|
|
|
+
|
|
|
fd = open("/dev/watchdog", O_WRONLY);
|
|
fd = open("/dev/watchdog", O_WRONLY);
|
|
|
|
|
|
|
|
if (fd == -1) {
|
|
if (fd == -1) {
|
|
|
- fprintf(stderr, "Watchdog device not enabled.\n");
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("Watchdog device not enabled.\n");
|
|
|
exit(-1);
|
|
exit(-1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -55,36 +57,30 @@ int main(int argc, char *argv[])
|
|
|
if (!strncasecmp(argv[1], "-d", 2)) {
|
|
if (!strncasecmp(argv[1], "-d", 2)) {
|
|
|
flags = WDIOS_DISABLECARD;
|
|
flags = WDIOS_DISABLECARD;
|
|
|
ioctl(fd, WDIOC_SETOPTIONS, &flags);
|
|
ioctl(fd, WDIOC_SETOPTIONS, &flags);
|
|
|
- fprintf(stderr, "Watchdog card disabled.\n");
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("Watchdog card disabled.\n");
|
|
|
goto end;
|
|
goto end;
|
|
|
} else if (!strncasecmp(argv[1], "-e", 2)) {
|
|
} else if (!strncasecmp(argv[1], "-e", 2)) {
|
|
|
flags = WDIOS_ENABLECARD;
|
|
flags = WDIOS_ENABLECARD;
|
|
|
ioctl(fd, WDIOC_SETOPTIONS, &flags);
|
|
ioctl(fd, WDIOC_SETOPTIONS, &flags);
|
|
|
- fprintf(stderr, "Watchdog card enabled.\n");
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("Watchdog card enabled.\n");
|
|
|
goto end;
|
|
goto end;
|
|
|
} else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
|
|
} else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) {
|
|
|
flags = atoi(argv[2]);
|
|
flags = atoi(argv[2]);
|
|
|
ioctl(fd, WDIOC_SETTIMEOUT, &flags);
|
|
ioctl(fd, WDIOC_SETTIMEOUT, &flags);
|
|
|
- fprintf(stderr, "Watchdog timeout set to %u seconds.\n", flags);
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("Watchdog timeout set to %u seconds.\n", flags);
|
|
|
goto end;
|
|
goto end;
|
|
|
} else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
|
|
} else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) {
|
|
|
ping_rate = strtoul(argv[2], NULL, 0);
|
|
ping_rate = strtoul(argv[2], NULL, 0);
|
|
|
- fprintf(stderr, "Watchdog ping rate set to %u seconds.\n", ping_rate);
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("Watchdog ping rate set to %u seconds.\n", ping_rate);
|
|
|
} else {
|
|
} else {
|
|
|
- fprintf(stderr, "-d to disable, -e to enable, -t <n> to set " \
|
|
|
|
|
|
|
+ printf("-d to disable, -e to enable, -t <n> to set " \
|
|
|
"the timeout,\n-p <n> to set the ping rate, and \n");
|
|
"the timeout,\n-p <n> to set the ping rate, and \n");
|
|
|
- fprintf(stderr, "run by itself to tick the card.\n");
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("run by itself to tick the card.\n");
|
|
|
goto end;
|
|
goto end;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- fprintf(stderr, "Watchdog Ticking Away!\n");
|
|
|
|
|
- fflush(stderr);
|
|
|
|
|
|
|
+ printf("Watchdog Ticking Away!\n");
|
|
|
|
|
|
|
|
signal(SIGINT, term);
|
|
signal(SIGINT, term);
|
|
|
|
|
|