diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-14 21:55:41 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-03-14 21:55:41 +0000 |
commit | cfa2b3a20984811997b6f7f6fce2ea9b0d53e7f7 (patch) | |
tree | ee4de7e566ac86b212648b69aa1bf57e6007761b /miscutils/watchdog.c | |
parent | 1ce190b7c1a1af40c1b12f69036e10b9a96ea2c8 (diff) | |
download | busybox-w32-cfa2b3a20984811997b6f7f6fce2ea9b0d53e7f7.tar.gz busybox-w32-cfa2b3a20984811997b6f7f6fce2ea9b0d53e7f7.tar.bz2 busybox-w32-cfa2b3a20984811997b6f7f6fce2ea9b0d53e7f7.zip |
watchdog: don't use static variable
Diffstat (limited to 'miscutils/watchdog.c')
-rw-r--r-- | miscutils/watchdog.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c index 9dbefb985..ed9026d9e 100644 --- a/miscutils/watchdog.c +++ b/miscutils/watchdog.c | |||
@@ -13,13 +13,12 @@ | |||
13 | #define OPT_FOREGROUND 0x01 | 13 | #define OPT_FOREGROUND 0x01 |
14 | #define OPT_TIMER 0x02 | 14 | #define OPT_TIMER 0x02 |
15 | 15 | ||
16 | /* Watchdog file descriptor */ | 16 | static void watchdog_shutdown(int ATTRIBUTE_UNUSED sig) ATTRIBUTE_NORETURN; |
17 | static int fd; | 17 | static void watchdog_shutdown(int ATTRIBUTE_UNUSED sig) |
18 | |||
19 | static void watchdog_shutdown(int ATTRIBUTE_UNUSED unused) | ||
20 | { | 18 | { |
21 | write(fd, "V", 1); /* Magic, see watchdog-api.txt in kernel */ | 19 | write(3, "V", 1); /* Magic, see watchdog-api.txt in kernel */ |
22 | close(fd); | 20 | if (ENABLE_FEATURE_CLEAN_UP) |
21 | close(3); | ||
23 | exit(0); | 22 | exit(0); |
24 | } | 23 | } |
25 | 24 | ||
@@ -49,18 +48,19 @@ int watchdog_main(int argc, char **argv) | |||
49 | signal(SIGHUP, watchdog_shutdown); | 48 | signal(SIGHUP, watchdog_shutdown); |
50 | signal(SIGINT, watchdog_shutdown); | 49 | signal(SIGINT, watchdog_shutdown); |
51 | 50 | ||
52 | fd = xopen(argv[argc - 1], O_WRONLY); | 51 | /* Use known fd # - avoid needing global 'int fd' */ |
52 | dup2(xopen(argv[argc - 1], O_WRONLY), 3); | ||
53 | 53 | ||
54 | while (1) { | 54 | while (1) { |
55 | /* | 55 | /* |
56 | * Make sure we clear the counter before sleeping, as the counter value | 56 | * Make sure we clear the counter before sleeping, as the counter value |
57 | * is undefined at this point -- PFM | 57 | * is undefined at this point -- PFM |
58 | */ | 58 | */ |
59 | write(fd, "\0", 1); | 59 | write(3, "", 1); |
60 | sleep(timer_duration); | 60 | sleep(timer_duration); |
61 | } | 61 | } |
62 | 62 | ||
63 | watchdog_shutdown(0); | 63 | watchdog_shutdown(0); |
64 | 64 | ||
65 | return EXIT_SUCCESS; | 65 | /* return EXIT_SUCCESS; */ |
66 | } | 66 | } |