diff options
author | Timur Tabi <timur@codeaurora.org> | 2016-06-21 19:00:14 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2016-07-17 15:02:29 -0400 |
commit | ee279c2734b07fb74031b1626b0f097cee9de5c8 (patch) | |
tree | 346ff165845200e1db5ccd6d97c479f6a8e1d8a5 /Documentation/watchdog | |
parent | 334da2d6753ba548851c6329c4b6e74eb731368a (diff) |
Documentation/watchdog: use stdout instead of stderr in watchdog-test
The watchdog-test utility outputs all messages to stderr, even those
that are not error messages. Output to stdout instead.
Instead of flushing the output after every write, just disabled
the output buffer.
Also display a dot for every ping of the watchdog, so that the user
knows that it's working.
Signed-off-by: Timur Tabi <timur@codeaurora.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'Documentation/watchdog')
-rw-r--r-- | Documentation/watchdog/src/watchdog-test.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/Documentation/watchdog/src/watchdog-test.c b/Documentation/watchdog/src/watchdog-test.c index fcdde8fc98be..b3cc7aa12a72 100644 --- a/Documentation/watchdog/src/watchdog-test.c +++ b/Documentation/watchdog/src/watchdog-test.c | |||
@@ -23,6 +23,7 @@ static void keep_alive(void) | |||
23 | { | 23 | { |
24 | int dummy; | 24 | int dummy; |
25 | 25 | ||
26 | printf("."); | ||
26 | ioctl(fd, WDIOC_KEEPALIVE, &dummy); | 27 | ioctl(fd, WDIOC_KEEPALIVE, &dummy); |
27 | } | 28 | } |
28 | 29 | ||
@@ -34,7 +35,7 @@ static void keep_alive(void) | |||
34 | static void term(int sig) | 35 | static void term(int sig) |
35 | { | 36 | { |
36 | close(fd); | 37 | close(fd); |
37 | fprintf(stderr, "Stopping watchdog ticks...\n"); | 38 | printf("\nStopping watchdog ticks...\n"); |
38 | exit(0); | 39 | exit(0); |
39 | } | 40 | } |
40 | 41 | ||
@@ -43,11 +44,12 @@ int main(int argc, char *argv[]) | |||
43 | int flags; | 44 | int flags; |
44 | unsigned int ping_rate = 1; | 45 | unsigned int ping_rate = 1; |
45 | 46 | ||
47 | setbuf(stdout, NULL); | ||
48 | |||
46 | fd = open("/dev/watchdog", O_WRONLY); | 49 | fd = open("/dev/watchdog", O_WRONLY); |
47 | 50 | ||
48 | if (fd == -1) { | 51 | if (fd == -1) { |
49 | fprintf(stderr, "Watchdog device not enabled.\n"); | 52 | printf("Watchdog device not enabled.\n"); |
50 | fflush(stderr); | ||
51 | exit(-1); | 53 | exit(-1); |
52 | } | 54 | } |
53 | 55 | ||
@@ -55,36 +57,30 @@ int main(int argc, char *argv[]) | |||
55 | if (!strncasecmp(argv[1], "-d", 2)) { | 57 | if (!strncasecmp(argv[1], "-d", 2)) { |
56 | flags = WDIOS_DISABLECARD; | 58 | flags = WDIOS_DISABLECARD; |
57 | ioctl(fd, WDIOC_SETOPTIONS, &flags); | 59 | ioctl(fd, WDIOC_SETOPTIONS, &flags); |
58 | fprintf(stderr, "Watchdog card disabled.\n"); | 60 | printf("Watchdog card disabled.\n"); |
59 | fflush(stderr); | ||
60 | goto end; | 61 | goto end; |
61 | } else if (!strncasecmp(argv[1], "-e", 2)) { | 62 | } else if (!strncasecmp(argv[1], "-e", 2)) { |
62 | flags = WDIOS_ENABLECARD; | 63 | flags = WDIOS_ENABLECARD; |
63 | ioctl(fd, WDIOC_SETOPTIONS, &flags); | 64 | ioctl(fd, WDIOC_SETOPTIONS, &flags); |
64 | fprintf(stderr, "Watchdog card enabled.\n"); | 65 | printf("Watchdog card enabled.\n"); |
65 | fflush(stderr); | ||
66 | goto end; | 66 | goto end; |
67 | } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) { | 67 | } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) { |
68 | flags = atoi(argv[2]); | 68 | flags = atoi(argv[2]); |
69 | ioctl(fd, WDIOC_SETTIMEOUT, &flags); | 69 | ioctl(fd, WDIOC_SETTIMEOUT, &flags); |
70 | fprintf(stderr, "Watchdog timeout set to %u seconds.\n", flags); | 70 | printf("Watchdog timeout set to %u seconds.\n", flags); |
71 | fflush(stderr); | ||
72 | goto end; | 71 | goto end; |
73 | } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) { | 72 | } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) { |
74 | ping_rate = strtoul(argv[2], NULL, 0); | 73 | ping_rate = strtoul(argv[2], NULL, 0); |
75 | fprintf(stderr, "Watchdog ping rate set to %u seconds.\n", ping_rate); | 74 | printf("Watchdog ping rate set to %u seconds.\n", ping_rate); |
76 | fflush(stderr); | ||
77 | } else { | 75 | } else { |
78 | fprintf(stderr, "-d to disable, -e to enable, -t <n> to set " \ | 76 | printf("-d to disable, -e to enable, -t <n> to set " \ |
79 | "the timeout,\n-p <n> to set the ping rate, and \n"); | 77 | "the timeout,\n-p <n> to set the ping rate, and \n"); |
80 | fprintf(stderr, "run by itself to tick the card.\n"); | 78 | printf("run by itself to tick the card.\n"); |
81 | fflush(stderr); | ||
82 | goto end; | 79 | goto end; |
83 | } | 80 | } |
84 | } | 81 | } |
85 | 82 | ||
86 | fprintf(stderr, "Watchdog Ticking Away!\n"); | 83 | printf("Watchdog Ticking Away!\n"); |
87 | fflush(stderr); | ||
88 | 84 | ||
89 | signal(SIGINT, term); | 85 | signal(SIGINT, term); |
90 | 86 | ||