watchdog: don't use static variable
This commit is contained in:
parent
1ce190b7c1
commit
cfa2b3a209
@ -13,13 +13,12 @@
|
|||||||
#define OPT_FOREGROUND 0x01
|
#define OPT_FOREGROUND 0x01
|
||||||
#define OPT_TIMER 0x02
|
#define OPT_TIMER 0x02
|
||||||
|
|
||||||
/* Watchdog file descriptor */
|
static void watchdog_shutdown(int ATTRIBUTE_UNUSED sig) ATTRIBUTE_NORETURN;
|
||||||
static int fd;
|
static void watchdog_shutdown(int ATTRIBUTE_UNUSED sig)
|
||||||
|
|
||||||
static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused)
|
|
||||||
{
|
{
|
||||||
write(fd, "V", 1); /* Magic, see watchdog-api.txt in kernel */
|
write(3, "V", 1); /* Magic, see watchdog-api.txt in kernel */
|
||||||
close(fd);
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
|
close(3);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,18 +48,19 @@ int watchdog_main(int argc, char **argv)
|
|||||||
signal(SIGHUP, watchdog_shutdown);
|
signal(SIGHUP, watchdog_shutdown);
|
||||||
signal(SIGINT, watchdog_shutdown);
|
signal(SIGINT, watchdog_shutdown);
|
||||||
|
|
||||||
fd = xopen(argv[argc - 1], O_WRONLY);
|
/* Use known fd # - avoid needing global 'int fd' */
|
||||||
|
dup2(xopen(argv[argc - 1], O_WRONLY), 3);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/*
|
/*
|
||||||
* Make sure we clear the counter before sleeping, as the counter value
|
* Make sure we clear the counter before sleeping, as the counter value
|
||||||
* is undefined at this point -- PFM
|
* is undefined at this point -- PFM
|
||||||
*/
|
*/
|
||||||
write(fd, "\0", 1);
|
write(3, "", 1);
|
||||||
sleep(timer_duration);
|
sleep(timer_duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdog_shutdown(0);
|
watchdog_shutdown(0);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
/* return EXIT_SUCCESS; */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user