#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
int
main ()
{
- int fd, i;
+ int fd;
int timeout;
char input[256];
time_t start_t, t;
printf ("Do you want to start the test? Type \"yes\" without quotes:\n");
if (fgets (input, sizeof input, stdin) == NULL ||
- strcmp (input, "yes") != 0) {
+ strncmp (input, "yes", 3) != 0) {
printf ("Exiting the program.\n");
exit (EXIT_SUCCESS);
}
if (ioctl (fd, WDIOC_GETTIMEOUT, &timeout) == -1)
perror ("ioctl: WDIOC_GETTIMEOUT");
else {
- printf ("Timeout is set to %d seconds.\n");
+ printf ("Timeout is set to %d seconds.\n", timeout);
if (timeout != WATCHDOG_TIMEOUT)
printf ("Note: some watchdog devices don't support setting exact timeout values.\n");
}
sleep (3);
+ printf ("ping ");
if (ioctl (fd, WDIOC_KEEPALIVE, 0) == -1)
- perror ("ioctl: WDIOC_KEEPALIVE");
- printf ("* ");
+ perror ("\nioctl: WDIOC_KEEPALIVE");
}
printf ("\n");
+ printf ("\n");
printf ("Stopping pings.\n");
- printf ("The watchdog action should happen at around %d mark.\n");
+ printf ("The watchdog action should happen at approximately %d second mark.\n",
+ WATCHDOG_TIMEOUT);
printf ("\n");
time (&start_t);