aboutsummaryrefslogtreecommitdiff
path: root/Documentation/watchdog
diff options
context:
space:
mode:
authorDevendra Naga <devendra.aaru@gmail.com>2012-05-14 23:42:02 +0530
committerWim Van Sebroeck <wim@iguana.be>2012-05-23 16:27:40 +0200
commit3c2a6186c1a69d647e3a48ad3f7f9078c451111e (patch)
tree4c88ca07108376d64fa29a43cbdff3e245a2a676 /Documentation/watchdog
parent2deca7365582b7568dbdd2c3d9eef7ac17d41fd6 (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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c
index 63fdc34ceb9..23084f22127 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[])
ioctl(fd, WDIOC_SETOPTIONS, &flags);
fprintf(stderr, "Watchdog card disabled.\n");
fflush(stderr);
- exit(0);
+ goto end;
} else if (!strncasecmp(argv[1], "-e", 2)) {
flags = WDIOS_ENABLECARD;
ioctl(fd, WDIOC_SETOPTIONS, &flags);
fprintf(stderr, "Watchdog card enabled.\n");
fflush(stderr);
- exit(0);
+ goto end;
} else {
fprintf(stderr, "-d to disable, -e to enable.\n");
fprintf(stderr, "run by itself to tick the card.\n");
fflush(stderr);
- exit(0);
+ goto end;
}
} else {
fprintf(stderr, "Watchdog Ticking Away!\n");
@@ -69,4 +69,7 @@ int main(int argc, char *argv[])
keep_alive();
sleep(1);
}
+end:
+ close(fd);
+ return 0;
}