diff options
author | Devendra Naga <devendra.aaru@gmail.com> | 2012-05-14 14:12:02 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2012-05-23 10:27:40 -0400 |
commit | 3c2a6186c1a69d647e3a48ad3f7f9078c451111e (patch) | |
tree | 4c88ca07108376d64fa29a43cbdff3e245a2a676 /Documentation/watchdog | |
parent | 2deca7365582b7568dbdd2c3d9eef7ac17d41fd6 (diff) |
Documentation/watchdog: close the fd when cmdline arg given
in the watchdog test code, the ioctl is performed on the watchdog device
and just doing exit(0) so we leak a filedescripor.
Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'Documentation/watchdog')
-rw-r--r-- | Documentation/watchdog/src/watchdog-test.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c index 63fdc34ceb98..23084f221279 100644 --- a/Documentation/watchdog/src/watchdog-test.c +++ b/Documentation/watchdog/src/watchdog-test.c | |||
@@ -47,18 +47,18 @@ int main(int argc, char *argv[]) | |||
47 | ioctl(fd, WDIOC_SETOPTIONS, &flags); | 47 | ioctl(fd, WDIOC_SETOPTIONS, &flags); |
48 | fprintf(stderr, "Watchdog card disabled.\n"); | 48 | fprintf(stderr, "Watchdog card disabled.\n"); |
49 | fflush(stderr); | 49 | fflush(stderr); |
50 | exit(0); | 50 | goto end; |
51 | } else if (!strncasecmp(argv[1], "-e", 2)) { | 51 | } else if (!strncasecmp(argv[1], "-e", 2)) { |
52 | flags = WDIOS_ENABLECARD; | 52 | flags = WDIOS_ENABLECARD; |
53 | ioctl(fd, WDIOC_SETOPTIONS, &flags); | 53 | ioctl(fd, WDIOC_SETOPTIONS, &flags); |
54 | fprintf(stderr, "Watchdog card enabled.\n"); | 54 | fprintf(stderr, "Watchdog card enabled.\n"); |
55 | fflush(stderr); | 55 | fflush(stderr); |
56 | exit(0); | 56 | goto end; |
57 | } else { | 57 | } else { |
58 | fprintf(stderr, "-d to disable, -e to enable.\n"); | 58 | fprintf(stderr, "-d to disable, -e to enable.\n"); |
59 | fprintf(stderr, "run by itself to tick the card.\n"); | 59 | fprintf(stderr, "run by itself to tick the card.\n"); |
60 | fflush(stderr); | 60 | fflush(stderr); |
61 | exit(0); | 61 | goto end; |
62 | } | 62 | } |
63 | } else { | 63 | } else { |
64 | fprintf(stderr, "Watchdog Ticking Away!\n"); | 64 | fprintf(stderr, "Watchdog Ticking Away!\n"); |
@@ -69,4 +69,7 @@ int main(int argc, char *argv[]) | |||
69 | keep_alive(); | 69 | keep_alive(); |
70 | sleep(1); | 70 | sleep(1); |
71 | } | 71 | } |
72 | end: | ||
73 | close(fd); | ||
74 | return 0; | ||
72 | } | 75 | } |