Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Timur Tabi and committed by
Wim Van Sebroeck
ee279c27 334da2d6

+12 -16
+12 -16
Documentation/watchdog/src/watchdog-test.c
··· 23 23 { 24 24 int dummy; 25 25 26 + printf("."); 26 27 ioctl(fd, WDIOC_KEEPALIVE, &dummy); 27 28 } 28 29 ··· 35 34 static void term(int sig) 36 35 { 37 36 close(fd); 38 - fprintf(stderr, "Stopping watchdog ticks...\n"); 37 + printf("\nStopping watchdog ticks...\n"); 39 38 exit(0); 40 39 } 41 40 ··· 44 43 int flags; 45 44 unsigned int ping_rate = 1; 46 45 46 + setbuf(stdout, NULL); 47 + 47 48 fd = open("/dev/watchdog", O_WRONLY); 48 49 49 50 if (fd == -1) { 50 - fprintf(stderr, "Watchdog device not enabled.\n"); 51 - fflush(stderr); 51 + printf("Watchdog device not enabled.\n"); 52 52 exit(-1); 53 53 } 54 54 ··· 57 55 if (!strncasecmp(argv[1], "-d", 2)) { 58 56 flags = WDIOS_DISABLECARD; 59 57 ioctl(fd, WDIOC_SETOPTIONS, &flags); 60 - fprintf(stderr, "Watchdog card disabled.\n"); 61 - fflush(stderr); 58 + printf("Watchdog card disabled.\n"); 62 59 goto end; 63 60 } else if (!strncasecmp(argv[1], "-e", 2)) { 64 61 flags = WDIOS_ENABLECARD; 65 62 ioctl(fd, WDIOC_SETOPTIONS, &flags); 66 - fprintf(stderr, "Watchdog card enabled.\n"); 67 - fflush(stderr); 63 + printf("Watchdog card enabled.\n"); 68 64 goto end; 69 65 } else if (!strncasecmp(argv[1], "-t", 2) && argv[2]) { 70 66 flags = atoi(argv[2]); 71 67 ioctl(fd, WDIOC_SETTIMEOUT, &flags); 72 - fprintf(stderr, "Watchdog timeout set to %u seconds.\n", flags); 73 - fflush(stderr); 68 + printf("Watchdog timeout set to %u seconds.\n", flags); 74 69 goto end; 75 70 } else if (!strncasecmp(argv[1], "-p", 2) && argv[2]) { 76 71 ping_rate = strtoul(argv[2], NULL, 0); 77 - fprintf(stderr, "Watchdog ping rate set to %u seconds.\n", ping_rate); 78 - fflush(stderr); 72 + printf("Watchdog ping rate set to %u seconds.\n", ping_rate); 79 73 } else { 80 - fprintf(stderr, "-d to disable, -e to enable, -t <n> to set " \ 74 + printf("-d to disable, -e to enable, -t <n> to set " \ 81 75 "the timeout,\n-p <n> to set the ping rate, and \n"); 82 - fprintf(stderr, "run by itself to tick the card.\n"); 83 - fflush(stderr); 76 + printf("run by itself to tick the card.\n"); 84 77 goto end; 85 78 } 86 79 } 87 80 88 - fprintf(stderr, "Watchdog Ticking Away!\n"); 89 - fflush(stderr); 81 + printf("Watchdog Ticking Away!\n"); 90 82 91 83 signal(SIGINT, term); 92 84