#include <errno.h>
#include <stdio.h>
#include <string.h>
extern char *__progname;
extern int __wdog_testmode;
#define DEBUG(fmt, args...) if (dbg) printf("%s: " fmt "\n", __progname, ##args);
#define PERROR(fmt, args...) if (dbg) fprintf(stderr, "%s: " fmt ": %s\n", __progname, ##args, strerror(errno));
int main(int argc, char *argv[])
{
int id, i, dbg = 0;
unsigned int ack = -1;
if (argc >= 2 && !strncmp(argv[1], "-V", 2))
dbg = 1;
DEBUG("Checking connectivity with watchdogd ...");
if (wdog_ping()) {
PERROR("Failed connectivity check");
return 1;
}
DEBUG("OK (debug:%d)!", id);
printf(
"Reset counter: %u\n", reason.
counter);
printf(
"Process wid %d, label %s\n", reason.
wid, reason.
label);
break;
default:
break;
}
if (id < 0) {
perror("Failed connecting to wdog");
return 1;
}
printf("Press Ctrl-C to exit.\n");
for (i = 0; i < 200; i++) {
DEBUG("Kicking ...");
PERROR("Failed kicking");
sleep(1);
if (i == 30)
wdog_forced_reset("Terminal failure");
}
DEBUG("Exiting ...");
PERROR("Failed unsubscribe");
return 1;
}
return 0;
}