提交 3c2a6186 编写于 作者: D Devendra Naga 提交者: Wim Van Sebroeck

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: NDevendra Naga <devendra.aaru@gmail.com>
Signed-off-by: NWim Van Sebroeck <wim@iguana.be>
上级 2deca736
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册