#define WATCHDOG_DEVICE "/dev/watchdog"
#define WATCHDOG_TIMEOUT_DEFAULT 30
+#define MIN(a,b) ((a)<(b)?(a):(b))
+
enum { HELP_OPTION = CHAR_MAX + 1 };
static const char *options = "";
main (int argc, char *argv[])
{
int watchdog_timeout = WATCHDOG_TIMEOUT_DEFAULT;
+ int ping_time;
int fd;
int timeout;
char input[256];
}
}
+ ping_time = MIN (watchdog_timeout * 2, 120);
+
setvbuf (stdout, NULL, _IONBF, 0);
printf ("\n");
watchdog_timeout);
printf ("(2) I will ping the watchdog for %d seconds. During this time\n"
" the guest should run normally.\n",
- watchdog_timeout * 2);
+ ping_time);
printf ("(3) I will stop pinging the watchdog and just count up. If the\n"
" virtual watchdog device is set correctly, then the watchdog\n"
" action (eg. reboot) should happen around the %d second mark.\n",
}
printf ("\n");
- printf ("Pinging the watchdog for %d seconds ...\n", watchdog_timeout*2);
+ printf ("Pinging the watchdog for %d seconds ...\n", ping_time);
printf ("\n");
time (&start_t);
for (;;) {
time (&t);
- if (t - start_t > watchdog_timeout * 2)
+ if (t - start_t > ping_time)
break;
printf ("%d...\n", (int) (t - start_t));