31
if (freopen("/dev/null", "r", stdin) == NULL)
32
err(1, "reopen stdin");
33
if(freopen("/dev/null", "w", stdout) == NULL)
34
err(1, "reopen stdout");
35
if(freopen("/dev/null", "w", stderr) == NULL)
36
err(1, "reopen stderr");
39
void catch_exit(int sig)
42
xc_watchdog(h, id, 300);
46
void catch_usr1(int sig)
49
xc_watchdog(h, id, 0);
53
int main(int argc, char **argv)
59
errx(1, "usage: %s <timeout> <sleep>", argv[0]);
63
h = xc_interface_open(NULL, NULL, 0);
65
err(1, "xc_interface_open");
67
t = strtoul(argv[1], NULL, 0);
73
s = strtoul(argv[2], NULL, 0);
78
if (signal(SIGHUP, &catch_exit) == SIG_ERR)
80
if (signal(SIGINT, &catch_exit) == SIG_ERR)
82
if (signal(SIGQUIT, &catch_exit) == SIG_ERR)
84
if (signal(SIGTERM, &catch_exit) == SIG_ERR)
86
if (signal(SIGUSR1, &catch_usr1) == SIG_ERR)
89
id = xc_watchdog(h, 0, t);
91
err(1, "xc_watchdog setup");
95
ret = xc_watchdog(h, id, t);
97
err(1, "xc_watchdog");