diff options
49 files changed, 84 insertions, 96 deletions
diff --git a/archival/cpio.c b/archival/cpio.c index ef228990a..41aeef171 100644 --- a/archival/cpio.c +++ b/archival/cpio.c | |||
@@ -252,7 +252,7 @@ static NOINLINE int cpio_o(void) | |||
252 | free(lpath); | 252 | free(lpath); |
253 | } else { /* S_ISREG */ | 253 | } else { /* S_ISREG */ |
254 | int fd = xopen(name, O_RDONLY); | 254 | int fd = xopen(name, O_RDONLY); |
255 | fflush(stdout); | 255 | fflush_all(); |
256 | /* We must abort if file got shorter too! */ | 256 | /* We must abort if file got shorter too! */ |
257 | bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size); | 257 | bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size); |
258 | bytes += st.st_size; | 258 | bytes += st.st_size; |
diff --git a/coreutils/dd.c b/coreutils/dd.c index 8bba62ce1..f1e63fd8b 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
@@ -189,7 +189,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv) | |||
189 | 189 | ||
190 | memset(&Z, 0, sizeof(Z)); | 190 | memset(&Z, 0, sizeof(Z)); |
191 | INIT_G(); | 191 | INIT_G(); |
192 | //fflush(NULL); - is this needed because of NOEXEC? | 192 | //fflush_all(); - is this needed because of NOEXEC? |
193 | 193 | ||
194 | for (n = 1; argv[n]; n++) { | 194 | for (n = 1; argv[n]; n++) { |
195 | int what; | 195 | int what; |
diff --git a/coreutils/dirname.c b/coreutils/dirname.c index c0c0925e5..1f5f70dfd 100644 --- a/coreutils/dirname.c +++ b/coreutils/dirname.c | |||
@@ -23,5 +23,5 @@ int dirname_main(int argc, char **argv) | |||
23 | 23 | ||
24 | puts(dirname(argv[1])); | 24 | puts(dirname(argv[1])); |
25 | 25 | ||
26 | return fflush(stdout); | 26 | return fflush_all(); |
27 | } | 27 | } |
diff --git a/coreutils/echo.c b/coreutils/echo.c index decca095f..69039969b 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
@@ -141,7 +141,7 @@ int echo_main(int argc UNUSED_PARAM, char **argv) | |||
141 | bb_putchar('\n'); | 141 | bb_putchar('\n'); |
142 | } | 142 | } |
143 | ret: | 143 | ret: |
144 | return fflush(stdout); | 144 | return fflush_all(); |
145 | } | 145 | } |
146 | 146 | ||
147 | /*- | 147 | /*- |
diff --git a/coreutils/hostid.c b/coreutils/hostid.c index 2794510a7..6f007d847 100644 --- a/coreutils/hostid.c +++ b/coreutils/hostid.c | |||
@@ -22,5 +22,5 @@ int hostid_main(int argc, char **argv UNUSED_PARAM) | |||
22 | 22 | ||
23 | printf("%lx\n", gethostid()); | 23 | printf("%lx\n", gethostid()); |
24 | 24 | ||
25 | return fflush(stdout); | 25 | return fflush_all(); |
26 | } | 26 | } |
diff --git a/coreutils/length.c b/coreutils/length.c index 43a0f5988..015b2216f 100644 --- a/coreutils/length.c +++ b/coreutils/length.c | |||
@@ -18,5 +18,5 @@ int length_main(int argc, char **argv) | |||
18 | 18 | ||
19 | printf("%u\n", (unsigned)strlen(*argv)); | 19 | printf("%u\n", (unsigned)strlen(*argv)); |
20 | 20 | ||
21 | return fflush(stdout); | 21 | return fflush_all(); |
22 | } | 22 | } |
diff --git a/coreutils/logname.c b/coreutils/logname.c index 7983d1704..7e5013255 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c | |||
@@ -36,7 +36,7 @@ int logname_main(int argc, char **argv UNUSED_PARAM) | |||
36 | /* Using _r function - avoid pulling in static buffer from libc */ | 36 | /* Using _r function - avoid pulling in static buffer from libc */ |
37 | if (getlogin_r(buf, sizeof(buf)) == 0) { | 37 | if (getlogin_r(buf, sizeof(buf)) == 0) { |
38 | puts(buf); | 38 | puts(buf); |
39 | return fflush(stdout); | 39 | return fflush_all(); |
40 | } | 40 | } |
41 | 41 | ||
42 | bb_perror_msg_and_die("getlogin"); | 42 | bb_perror_msg_and_die("getlogin"); |
diff --git a/coreutils/pwd.c b/coreutils/pwd.c index 57953d246..11278a2a5 100644 --- a/coreutils/pwd.c +++ b/coreutils/pwd.c | |||
@@ -20,7 +20,7 @@ int pwd_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
20 | if (buf != NULL) { | 20 | if (buf != NULL) { |
21 | puts(buf); | 21 | puts(buf); |
22 | free(buf); | 22 | free(buf); |
23 | return fflush(stdout); | 23 | return fflush_all(); |
24 | } | 24 | } |
25 | 25 | ||
26 | return EXIT_FAILURE; | 26 | return EXIT_FAILURE; |
diff --git a/coreutils/seq.c b/coreutils/seq.c index 03ae3c632..84d11fd8c 100644 --- a/coreutils/seq.c +++ b/coreutils/seq.c | |||
@@ -95,5 +95,5 @@ int seq_main(int argc, char **argv) | |||
95 | if (n) /* if while loop executed at least once */ | 95 | if (n) /* if while loop executed at least once */ |
96 | bb_putchar('\n'); | 96 | bb_putchar('\n'); |
97 | 97 | ||
98 | return fflush(stdout); | 98 | return fflush_all(); |
99 | } | 99 | } |
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 0dbcba955..1031cdbf8 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
@@ -22,5 +22,5 @@ int whoami_main(int argc, char **argv UNUSED_PARAM) | |||
22 | /* Will complain and die if username not found */ | 22 | /* Will complain and die if username not found */ |
23 | puts(xuid2uname(geteuid())); | 23 | puts(xuid2uname(geteuid())); |
24 | 24 | ||
25 | return fflush(stdout); | 25 | return fflush_all(); |
26 | } | 26 | } |
diff --git a/editors/awk.c b/editors/awk.c index bc1d93868..ce6c9b726 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -2552,7 +2552,7 @@ static var *evaluate(node *op, var *res) | |||
2552 | break; | 2552 | break; |
2553 | 2553 | ||
2554 | case F_sy: | 2554 | case F_sy: |
2555 | fflush(NULL); | 2555 | fflush_all(); |
2556 | R.d = (ENABLE_FEATURE_ALLOW_EXEC && L.s && *L.s) | 2556 | R.d = (ENABLE_FEATURE_ALLOW_EXEC && L.s && *L.s) |
2557 | ? (system(L.s) >> 8) : 0; | 2557 | ? (system(L.s) >> 8) : 0; |
2558 | break; | 2558 | break; |
@@ -2565,7 +2565,7 @@ static var *evaluate(node *op, var *res) | |||
2565 | X.rsm = newfile(L.s); | 2565 | X.rsm = newfile(L.s); |
2566 | fflush(X.rsm->F); | 2566 | fflush(X.rsm->F); |
2567 | } else { | 2567 | } else { |
2568 | fflush(NULL); | 2568 | fflush_all(); |
2569 | } | 2569 | } |
2570 | } | 2570 | } |
2571 | break; | 2571 | break; |
diff --git a/editors/cmp.c b/editors/cmp.c index a20bb8836..384e57c22 100644 --- a/editors/cmp.c +++ b/editors/cmp.c | |||
@@ -108,7 +108,7 @@ int cmp_main(int argc UNUSED_PARAM, char **argv) | |||
108 | outfile = stderr; | 108 | outfile = stderr; |
109 | /* There may have been output to stdout (option -l), so | 109 | /* There may have been output to stdout (option -l), so |
110 | * make sure we fflush before writing to stderr. */ | 110 | * make sure we fflush before writing to stderr. */ |
111 | xfflush_stdout(); | 111 | fflush_all(); |
112 | } | 112 | } |
113 | if (!(opt & CMP_OPT_s)) { | 113 | if (!(opt & CMP_OPT_s)) { |
114 | if (opt & CMP_OPT_l) { | 114 | if (opt & CMP_OPT_l) { |
diff --git a/editors/ed.c b/editors/ed.c index dbd802075..8ed4cd42b 100644 --- a/editors/ed.c +++ b/editors/ed.c | |||
@@ -686,7 +686,7 @@ static int readLines(const char *file, int num) | |||
686 | cc = 0; | 686 | cc = 0; |
687 | 687 | ||
688 | printf("\"%s\", ", file); | 688 | printf("\"%s\", ", file); |
689 | fflush(stdout); | 689 | fflush_all(); |
690 | 690 | ||
691 | do { | 691 | do { |
692 | cp = memchr(bufPtr, '\n', bufUsed); | 692 | cp = memchr(bufPtr, '\n', bufUsed); |
@@ -775,7 +775,7 @@ static int writeLines(const char *file, int num1, int num2) | |||
775 | } | 775 | } |
776 | 776 | ||
777 | printf("\"%s\", ", file); | 777 | printf("\"%s\", ", file); |
778 | fflush(stdout); | 778 | fflush_all(); |
779 | 779 | ||
780 | lp = findLine(num1); | 780 | lp = findLine(num1); |
781 | if (lp == NULL) { | 781 | if (lp == NULL) { |
diff --git a/editors/vi.c b/editors/vi.c index 82f302dca..1a3997a6b 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -2136,7 +2136,7 @@ static void rawmode(void) | |||
2136 | 2136 | ||
2137 | static void cookmode(void) | 2137 | static void cookmode(void) |
2138 | { | 2138 | { |
2139 | fflush(stdout); | 2139 | fflush_all(); |
2140 | tcsetattr_stdin_TCSANOW(&term_orig); | 2140 | tcsetattr_stdin_TCSANOW(&term_orig); |
2141 | } | 2141 | } |
2142 | 2142 | ||
@@ -2201,7 +2201,7 @@ static int readit(void) // read (maybe cursor) key from stdin | |||
2201 | { | 2201 | { |
2202 | int c; | 2202 | int c; |
2203 | 2203 | ||
2204 | fflush(stdout); | 2204 | fflush_all(); |
2205 | c = read_key(STDIN_FILENO, readbuffer); | 2205 | c = read_key(STDIN_FILENO, readbuffer); |
2206 | if (c == -1) { // EOF/error | 2206 | if (c == -1) { // EOF/error |
2207 | go_bottom_and_clear_to_eol(); | 2207 | go_bottom_and_clear_to_eol(); |
@@ -2555,7 +2555,7 @@ static void show_status_line(void) | |||
2555 | } | 2555 | } |
2556 | place_cursor(crow, ccol, FALSE); // put cursor back in correct place | 2556 | place_cursor(crow, ccol, FALSE); // put cursor back in correct place |
2557 | } | 2557 | } |
2558 | fflush(stdout); | 2558 | fflush_all(); |
2559 | } | 2559 | } |
2560 | 2560 | ||
2561 | //----- format the status buffer, the bottom line of screen ------ | 2561 | //----- format the status buffer, the bottom line of screen ------ |
@@ -3963,7 +3963,7 @@ static void crash_test() | |||
3963 | if (msg[0]) { | 3963 | if (msg[0]) { |
3964 | printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s", | 3964 | printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s", |
3965 | totalcmds, last_input_char, msg, SOs, SOn); | 3965 | totalcmds, last_input_char, msg, SOs, SOn); |
3966 | fflush(stdout); | 3966 | fflush_all(); |
3967 | while (safe_read(STDIN_FILENO, d, 1) > 0) { | 3967 | while (safe_read(STDIN_FILENO, d, 1) > 0) { |
3968 | if (d[0] == '\n' || d[0] == '\r') | 3968 | if (d[0] == '\n' || d[0] == '\r') |
3969 | break; | 3969 | break; |
diff --git a/findutils/xargs.c b/findutils/xargs.c index 76d1d5489..ab1a6d0a5 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -279,7 +279,7 @@ static int xargs_ask_confirmation(void) | |||
279 | 279 | ||
280 | tty_stream = xfopen_for_read(CURRENT_TTY); | 280 | tty_stream = xfopen_for_read(CURRENT_TTY); |
281 | fputs(" ?...", stderr); | 281 | fputs(" ?...", stderr); |
282 | fflush(stderr); | 282 | fflush_all(); |
283 | c = savec = getc(tty_stream); | 283 | c = savec = getc(tty_stream); |
284 | while (c != EOF && c != '\n') | 284 | while (c != EOF && c != '\n') |
285 | c = getc(tty_stream); | 285 | c = getc(tty_stream); |
diff --git a/include/libbb.h b/include/libbb.h index d2b74377e..955287c4d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -659,7 +659,7 @@ extern char *xmalloc_fgetline(FILE *file) FAST_FUNC; | |||
659 | 659 | ||
660 | extern void die_if_ferror(FILE *file, const char *msg) FAST_FUNC; | 660 | extern void die_if_ferror(FILE *file, const char *msg) FAST_FUNC; |
661 | extern void die_if_ferror_stdout(void) FAST_FUNC; | 661 | extern void die_if_ferror_stdout(void) FAST_FUNC; |
662 | extern void xfflush_stdout(void) FAST_FUNC; | 662 | extern int fflush_all(void) FAST_FUNC; |
663 | extern void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC; | 663 | extern void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC; |
664 | extern int fclose_if_not_stdin(FILE *file) FAST_FUNC; | 664 | extern int fclose_if_not_stdin(FILE *file) FAST_FUNC; |
665 | extern FILE *xfopen(const char *filename, const char *mode) FAST_FUNC; | 665 | extern FILE *xfopen(const char *filename, const char *mode) FAST_FUNC; |
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index 073175c1f..f9b918cec 100644 --- a/libbb/bb_askpass.c +++ b/libbb/bb_askpass.c | |||
@@ -55,7 +55,7 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt) | |||
55 | } | 55 | } |
56 | 56 | ||
57 | fputs(prompt, stdout); | 57 | fputs(prompt, stdout); |
58 | fflush(stdout); | 58 | fflush_all(); |
59 | ret = NULL; | 59 | ret = NULL; |
60 | /* On timeout or Ctrl-C, read will hopefully be interrupted, | 60 | /* On timeout or Ctrl-C, read will hopefully be interrupted, |
61 | * and we return NULL */ | 61 | * and we return NULL */ |
@@ -77,6 +77,6 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt) | |||
77 | 77 | ||
78 | tcsetattr_stdin_TCSANOW(&oldtio); | 78 | tcsetattr_stdin_TCSANOW(&oldtio); |
79 | bb_putchar('\n'); | 79 | bb_putchar('\n'); |
80 | fflush(stdout); | 80 | fflush_all(); |
81 | return ret; | 81 | return ret; |
82 | } | 82 | } |
diff --git a/libbb/info_msg.c b/libbb/info_msg.c index 8b8a1fcca..5f375d43b 100644 --- a/libbb/info_msg.c +++ b/libbb/info_msg.c | |||
@@ -44,7 +44,7 @@ void FAST_FUNC bb_info_msg(const char *s, ...) | |||
44 | if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) | 44 | if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) |
45 | syslog(LOG_INFO, "%s", msg); | 45 | syslog(LOG_INFO, "%s", msg); |
46 | if (logmode & LOGMODE_STDIO) { | 46 | if (logmode & LOGMODE_STDIO) { |
47 | fflush(stdout); | 47 | fflush_all(); |
48 | /* used = strlen(msg); - must be true already */ | 48 | /* used = strlen(msg); - must be true already */ |
49 | msg[used++] = '\n'; | 49 | msg[used++] = '\n'; |
50 | full_write(STDOUT_FILENO, msg, used); | 50 | full_write(STDOUT_FILENO, msg, used); |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 0f7ab8c94..a9972576e 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -373,7 +373,7 @@ static void input_backward(unsigned num) | |||
373 | static void put_prompt(void) | 373 | static void put_prompt(void) |
374 | { | 374 | { |
375 | out1str(cmdedit_prompt); | 375 | out1str(cmdedit_prompt); |
376 | fflush(NULL); | 376 | fflush_all(); |
377 | #if ENABLE_FEATURE_EDITING_ASK_TERMINAL | 377 | #if ENABLE_FEATURE_EDITING_ASK_TERMINAL |
378 | { | 378 | { |
379 | /* Ask terminal where is the cursor now. | 379 | /* Ask terminal where is the cursor now. |
@@ -411,7 +411,7 @@ static void put_prompt(void) | |||
411 | if (safe_poll(&pfd, 1, 0) == 0) { | 411 | if (safe_poll(&pfd, 1, 0) == 0) { |
412 | S.sent_ESC_br6n = 1; | 412 | S.sent_ESC_br6n = 1; |
413 | out1str("\033" "[6n"); | 413 | out1str("\033" "[6n"); |
414 | fflush(NULL); /* make terminal see it ASAP! */ | 414 | fflush_all(); /* make terminal see it ASAP! */ |
415 | } | 415 | } |
416 | } | 416 | } |
417 | #endif | 417 | #endif |
@@ -1636,7 +1636,7 @@ static void cmdedit_setwidth(unsigned w, int redraw_flg) | |||
1636 | int new_y = (cursor + cmdedit_prmt_len) / w; | 1636 | int new_y = (cursor + cmdedit_prmt_len) / w; |
1637 | /* redraw */ | 1637 | /* redraw */ |
1638 | redraw((new_y >= cmdedit_y ? new_y : cmdedit_y), command_len - cursor); | 1638 | redraw((new_y >= cmdedit_y ? new_y : cmdedit_y), command_len - cursor); |
1639 | fflush(NULL); | 1639 | fflush_all(); |
1640 | } | 1640 | } |
1641 | } | 1641 | } |
1642 | 1642 | ||
@@ -1748,7 +1748,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
1748 | ) { | 1748 | ) { |
1749 | /* Happens when e.g. stty -echo was run before */ | 1749 | /* Happens when e.g. stty -echo was run before */ |
1750 | parse_and_put_prompt(prompt); | 1750 | parse_and_put_prompt(prompt); |
1751 | /* fflush(stdout); - done by parse_and_put_prompt */ | 1751 | /* fflush_all(); - done by parse_and_put_prompt */ |
1752 | if (fgets(command, maxsize, stdin) == NULL) | 1752 | if (fgets(command, maxsize, stdin) == NULL) |
1753 | len = -1; /* EOF or error */ | 1753 | len = -1; /* EOF or error */ |
1754 | else | 1754 | else |
@@ -1841,7 +1841,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
1841 | }; | 1841 | }; |
1842 | int32_t ic, ic_raw; | 1842 | int32_t ic, ic_raw; |
1843 | 1843 | ||
1844 | fflush(NULL); | 1844 | fflush_all(); |
1845 | ic = ic_raw = lineedit_read_key(read_key_buffer); | 1845 | ic = ic_raw = lineedit_read_key(read_key_buffer); |
1846 | 1846 | ||
1847 | #if ENABLE_FEATURE_EDITING_VI | 1847 | #if ENABLE_FEATURE_EDITING_VI |
@@ -2245,7 +2245,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2245 | tcsetattr_stdin_TCSANOW(&initial_settings); | 2245 | tcsetattr_stdin_TCSANOW(&initial_settings); |
2246 | /* restore SIGWINCH handler */ | 2246 | /* restore SIGWINCH handler */ |
2247 | signal(SIGWINCH, previous_SIGWINCH_handler); | 2247 | signal(SIGWINCH, previous_SIGWINCH_handler); |
2248 | fflush(NULL); | 2248 | fflush_all(); |
2249 | 2249 | ||
2250 | len = command_len; | 2250 | len = command_len; |
2251 | DEINIT_S(); | 2251 | DEINIT_S(); |
@@ -2259,7 +2259,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
2259 | int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) | 2259 | int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) |
2260 | { | 2260 | { |
2261 | fputs(prompt, stdout); | 2261 | fputs(prompt, stdout); |
2262 | fflush(NULL); | 2262 | fflush_all(); |
2263 | fgets(command, maxsize, stdin); | 2263 | fgets(command, maxsize, stdin); |
2264 | return strlen(command); | 2264 | return strlen(command); |
2265 | } | 2265 | } |
diff --git a/libbb/login.c b/libbb/login.c index 07247a8c5..740c588f3 100644 --- a/libbb/login.c +++ b/libbb/login.c | |||
@@ -85,7 +85,7 @@ void FAST_FUNC print_login_issue(const char *issue_file, const char *tty) | |||
85 | fputs(outbuf, stdout); | 85 | fputs(outbuf, stdout); |
86 | } | 86 | } |
87 | fclose(fp); | 87 | fclose(fp); |
88 | fflush(stdout); | 88 | fflush_all(); |
89 | } | 89 | } |
90 | 90 | ||
91 | void FAST_FUNC print_login_prompt(void) | 91 | void FAST_FUNC print_login_prompt(void) |
@@ -94,7 +94,7 @@ void FAST_FUNC print_login_prompt(void) | |||
94 | 94 | ||
95 | fputs(hostname, stdout); | 95 | fputs(hostname, stdout); |
96 | fputs(LOGIN, stdout); | 96 | fputs(LOGIN, stdout); |
97 | fflush(stdout); | 97 | fflush_all(); |
98 | free(hostname); | 98 | free(hostname); |
99 | } | 99 | } |
100 | 100 | ||
diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 506b9066a..70f792f39 100644 --- a/libbb/verror_msg.c +++ b/libbb/verror_msg.c | |||
@@ -64,7 +64,7 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) | |||
64 | } | 64 | } |
65 | 65 | ||
66 | if (logmode & LOGMODE_STDIO) { | 66 | if (logmode & LOGMODE_STDIO) { |
67 | fflush(stdout); | 67 | fflush_all(); |
68 | full_write(STDERR_FILENO, msg, used); | 68 | full_write(STDERR_FILENO, msg, used); |
69 | } | 69 | } |
70 | if (logmode & LOGMODE_SYSLOG) { | 70 | if (logmode & LOGMODE_SYSLOG) { |
@@ -125,8 +125,8 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) | |||
125 | iov[1].iov_len = 2; | 125 | iov[1].iov_len = 2; |
126 | /*iov[2].iov_base = msgc;*/ | 126 | /*iov[2].iov_base = msgc;*/ |
127 | /*iov[2].iov_len = used;*/ | 127 | /*iov[2].iov_len = used;*/ |
128 | fflush(stdout); | 128 | fflush_all(); |
129 | writev(2, iov, 3); | 129 | writev(STDERR_FILENO, iov, 3); |
130 | } | 130 | } |
131 | if (logmode & LOGMODE_SYSLOG) { | 131 | if (logmode & LOGMODE_SYSLOG) { |
132 | syslog(LOG_ERR, "%s", msgc); | 132 | syslog(LOG_ERR, "%s", msgc); |
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 27efb0e37..9be901722 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -25,7 +25,7 @@ pid_t FAST_FUNC spawn(char **argv) | |||
25 | volatile int failed; | 25 | volatile int failed; |
26 | pid_t pid; | 26 | pid_t pid; |
27 | 27 | ||
28 | // Ain't it a good place to fflush(NULL)? | 28 | fflush_all(); |
29 | 29 | ||
30 | /* Be nice to nommu machines. */ | 30 | /* Be nice to nommu machines. */ |
31 | failed = 0; | 31 | failed = 0; |
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 241887ace..644134a0e 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -255,12 +255,9 @@ void FAST_FUNC die_if_ferror_stdout(void) | |||
255 | die_if_ferror(stdout, bb_msg_standard_output); | 255 | die_if_ferror(stdout, bb_msg_standard_output); |
256 | } | 256 | } |
257 | 257 | ||
258 | // Die with an error message if we have trouble flushing stdout. | 258 | int FAST_FUNC fflush_all(void) |
259 | void FAST_FUNC xfflush_stdout(void) | ||
260 | { | 259 | { |
261 | if (fflush(stdout)) { | 260 | return fflush(NULL); |
262 | bb_perror_msg_and_die(bb_msg_standard_output); | ||
263 | } | ||
264 | } | 261 | } |
265 | 262 | ||
266 | 263 | ||
@@ -276,9 +273,9 @@ int FAST_FUNC bb_putchar(int ch) | |||
276 | * then close that file. */ | 273 | * then close that file. */ |
277 | void FAST_FUNC xprint_and_close_file(FILE *file) | 274 | void FAST_FUNC xprint_and_close_file(FILE *file) |
278 | { | 275 | { |
279 | fflush(stdout); | 276 | fflush_all(); |
280 | // copyfd outputs error messages for us. | 277 | // copyfd outputs error messages for us. |
281 | if (bb_copyfd_eof(fileno(file), 1) == -1) | 278 | if (bb_copyfd_eof(fileno(file), STDOUT_FILENO) == -1) |
282 | xfunc_die(); | 279 | xfunc_die(); |
283 | 280 | ||
284 | fclose(file); | 281 | fclose(file); |
diff --git a/loginutils/login.c b/loginutils/login.c index c3e31d05d..1ffa965c2 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -137,7 +137,7 @@ static void die_if_nologin(void) | |||
137 | puts("\r\nSystem closed for routine maintenance\r"); | 137 | puts("\r\nSystem closed for routine maintenance\r"); |
138 | 138 | ||
139 | fclose(fp); | 139 | fclose(fp); |
140 | fflush(NULL); | 140 | fflush_all(); |
141 | /* Users say that they do need this prior to exit: */ | 141 | /* Users say that they do need this prior to exit: */ |
142 | tcdrain(STDOUT_FILENO); | 142 | tcdrain(STDOUT_FILENO); |
143 | exit(EXIT_FAILURE); | 143 | exit(EXIT_FAILURE); |
@@ -250,7 +250,7 @@ static void motd(void) | |||
250 | 250 | ||
251 | fd = open(bb_path_motd_file, O_RDONLY); | 251 | fd = open(bb_path_motd_file, O_RDONLY); |
252 | if (fd >= 0) { | 252 | if (fd >= 0) { |
253 | fflush(stdout); | 253 | fflush_all(); |
254 | bb_copyfd_eof(fd, STDOUT_FILENO); | 254 | bb_copyfd_eof(fd, STDOUT_FILENO); |
255 | close(fd); | 255 | close(fd); |
256 | } | 256 | } |
@@ -263,7 +263,7 @@ static void alarm_handler(int sig UNUSED_PARAM) | |||
263 | * We don't want to block here */ | 263 | * We don't want to block here */ |
264 | ndelay_on(1); | 264 | ndelay_on(1); |
265 | printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT); | 265 | printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT); |
266 | fflush(NULL); | 266 | fflush_all(); |
267 | /* unix API is brain damaged regarding O_NONBLOCK, | 267 | /* unix API is brain damaged regarding O_NONBLOCK, |
268 | * we should undo it, or else we can affect other processes */ | 268 | * we should undo it, or else we can affect other processes */ |
269 | ndelay_off(1); | 269 | ndelay_off(1); |
diff --git a/mailutils/mail.c b/mailutils/mail.c index 68883ff42..64a5b996f 100644 --- a/mailutils/mail.c +++ b/mailutils/mail.c | |||
@@ -87,7 +87,7 @@ const FAST_FUNC char *command(const char *fmt, const char *param) | |||
87 | msg = xasprintf(fmt, param); | 87 | msg = xasprintf(fmt, param); |
88 | printf("%s\r\n", msg); | 88 | printf("%s\r\n", msg); |
89 | } | 89 | } |
90 | fflush(stdout); | 90 | fflush_all(); |
91 | return msg; | 91 | return msg; |
92 | } | 92 | } |
93 | 93 | ||
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c index 4f3e94dc1..ba0a6b515 100644 --- a/miscutils/flash_eraseall.c +++ b/miscutils/flash_eraseall.c | |||
@@ -43,7 +43,7 @@ static void show_progress(mtd_info_t *meminfo, erase_info_t *erase) | |||
43 | printf("\rErasing %d Kibyte @ %x -- %2llu %% complete.", | 43 | printf("\rErasing %d Kibyte @ %x -- %2llu %% complete.", |
44 | (unsigned)meminfo->erasesize / 1024, erase->start, | 44 | (unsigned)meminfo->erasesize / 1024, erase->start, |
45 | (unsigned long long) erase->start * 100 / meminfo->size); | 45 | (unsigned long long) erase->start * 100 / meminfo->size); |
46 | fflush(stdout); | 46 | fflush_all(); |
47 | } | 47 | } |
48 | 48 | ||
49 | int flash_eraseall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 49 | int flash_eraseall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index c4d2f3b03..399b77a4a 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -1406,7 +1406,7 @@ static void do_time(int cache /*,int fd*/) | |||
1406 | } else { /* Time device */ | 1406 | } else { /* Time device */ |
1407 | printf("Timing buffered disk reads:"); | 1407 | printf("Timing buffered disk reads:"); |
1408 | } | 1408 | } |
1409 | fflush(stdout); | 1409 | fflush_all(); |
1410 | 1410 | ||
1411 | /* Now do the timing */ | 1411 | /* Now do the timing */ |
1412 | iterations = 0; | 1412 | iterations = 0; |
diff --git a/miscutils/less.c b/miscutils/less.c index ce77ddd3a..48f3a751f 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -157,7 +157,7 @@ struct globals { | |||
157 | /* Reset terminal input to normal */ | 157 | /* Reset terminal input to normal */ |
158 | static void set_tty_cooked(void) | 158 | static void set_tty_cooked(void) |
159 | { | 159 | { |
160 | fflush(stdout); | 160 | fflush_all(); |
161 | tcsetattr(kbd_fd, TCSANOW, &term_orig); | 161 | tcsetattr(kbd_fd, TCSANOW, &term_orig); |
162 | } | 162 | } |
163 | 163 | ||
@@ -835,7 +835,7 @@ static int getch_nowait(void) | |||
835 | /* Position cursor if line input is done */ | 835 | /* Position cursor if line input is done */ |
836 | if (less_gets_pos >= 0) | 836 | if (less_gets_pos >= 0) |
837 | move_cursor(max_displayed_line + 2, less_gets_pos + 1); | 837 | move_cursor(max_displayed_line + 2, less_gets_pos + 1); |
838 | fflush(stdout); | 838 | fflush_all(); |
839 | 839 | ||
840 | if (kbd_input[0] == 0) { /* if nothing is buffered */ | 840 | if (kbd_input[0] == 0) { /* if nothing is buffered */ |
841 | #if ENABLE_FEATURE_LESS_WINCH | 841 | #if ENABLE_FEATURE_LESS_WINCH |
diff --git a/networking/arping.c b/networking/arping.c index 71690cf30..e3418a945 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -237,7 +237,7 @@ static bool recv_pack(unsigned char *buf, int len, struct sockaddr_ll *FROM) | |||
237 | } else { | 237 | } else { |
238 | printf(" UNSOLICITED?\n"); | 238 | printf(" UNSOLICITED?\n"); |
239 | } | 239 | } |
240 | fflush(stdout); | 240 | fflush_all(); |
241 | } | 241 | } |
242 | received++; | 242 | received++; |
243 | if (FROM->sll_pkttype != PACKET_HOST) | 243 | if (FROM->sll_pkttype != PACKET_HOST) |
diff --git a/networking/ftpd.c b/networking/ftpd.c index 70a353312..9937cc3ea 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c | |||
@@ -630,7 +630,7 @@ popen_ls(const char *opt) | |||
630 | cwd = xrealloc_getcwd_or_warn(NULL); | 630 | cwd = xrealloc_getcwd_or_warn(NULL); |
631 | xpiped_pair(outfd); | 631 | xpiped_pair(outfd); |
632 | 632 | ||
633 | /*fflush(NULL); - so far we dont use stdio on output */ | 633 | /*fflush_all(); - so far we dont use stdio on output */ |
634 | pid = BB_MMU ? fork() : vfork(); | 634 | pid = BB_MMU ? fork() : vfork(); |
635 | if (pid < 0) | 635 | if (pid < 0) |
636 | bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork"); | 636 | bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork"); |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index d0c5cce07..88d1944da 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -969,7 +969,7 @@ static int doit(char *str) | |||
969 | pid_t child; | 969 | pid_t child; |
970 | int status; | 970 | int status; |
971 | 971 | ||
972 | fflush(NULL); | 972 | fflush_all(); |
973 | child = vfork(); | 973 | child = vfork(); |
974 | switch (child) { | 974 | switch (child) { |
975 | case -1: /* failure */ | 975 | case -1: /* failure */ |
@@ -1038,7 +1038,7 @@ static int popen2(FILE **in, FILE **out, char *command, char *param) | |||
1038 | xpiped_pair(infd); | 1038 | xpiped_pair(infd); |
1039 | xpiped_pair(outfd); | 1039 | xpiped_pair(outfd); |
1040 | 1040 | ||
1041 | fflush(NULL); | 1041 | fflush_all(); |
1042 | pid = vfork(); | 1042 | pid = vfork(); |
1043 | 1043 | ||
1044 | switch (pid) { | 1044 | switch (pid) { |
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 86d27548b..fcf9623e4 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -182,7 +182,7 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n) | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | bb_putchar('\n'); | 184 | bb_putchar('\n'); |
185 | /*fflush(stdout);*/ | 185 | /*fflush_all();*/ |
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
@@ -344,7 +344,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM, | |||
344 | printf(" %s", buf); | 344 | printf(" %s", buf); |
345 | } | 345 | } |
346 | bb_putchar('\n'); | 346 | bb_putchar('\n'); |
347 | /*fflush(stdout);*/ | 347 | /*fflush_all();*/ |
348 | return 0; | 348 | return 0; |
349 | } | 349 | } |
350 | 350 | ||
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index e52473117..659f3a9f0 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c | |||
@@ -151,7 +151,7 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
151 | fputs(rtnl_rtntype_n2a(r->rtm_type, b1), stdout); | 151 | fputs(rtnl_rtntype_n2a(r->rtm_type, b1), stdout); |
152 | 152 | ||
153 | bb_putchar('\n'); | 153 | bb_putchar('\n'); |
154 | /*fflush(stdout);*/ | 154 | /*fflush_all();*/ |
155 | return 0; | 155 | return 0; |
156 | } | 156 | } |
157 | 157 | ||
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index 9aaeec100..ad98bed30 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -152,7 +152,7 @@ enum { | |||
152 | /* Debug: squirt whatever message and sleep a bit so we can see it go by. */ | 152 | /* Debug: squirt whatever message and sleep a bit so we can see it go by. */ |
153 | /* Beware: writes to stdOUT... */ | 153 | /* Beware: writes to stdOUT... */ |
154 | #if 0 | 154 | #if 0 |
155 | #define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush(stdout); sleep(1); } while (0) | 155 | #define Debug(...) do { printf(__VA_ARGS__); printf("\n"); fflush_all(); sleep(1); } while (0) |
156 | #else | 156 | #else |
157 | #define Debug(...) do { } while (0) | 157 | #define Debug(...) do { } while (0) |
158 | #endif | 158 | #endif |
diff --git a/networking/ping.c b/networking/ping.c index 71b2a4be8..d30eb5cfa 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -491,7 +491,7 @@ static void unpack_tail(int sz, uint32_t *tp, | |||
491 | if (tp) | 491 | if (tp) |
492 | printf(" time=%u.%03u ms", triptime / 1000, triptime % 1000); | 492 | printf(" time=%u.%03u ms", triptime / 1000, triptime % 1000); |
493 | puts(dupmsg); | 493 | puts(dupmsg); |
494 | fflush(stdout); | 494 | fflush_all(); |
495 | } | 495 | } |
496 | static void unpack4(char *buf, int sz, struct sockaddr_in *from) | 496 | static void unpack4(char *buf, int sz, struct sockaddr_in *from) |
497 | { | 497 | { |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 163efaa42..b0a1cc4d8 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -288,7 +288,7 @@ make_new_session( | |||
288 | /*ts->size2 = 0;*/ | 288 | /*ts->size2 = 0;*/ |
289 | } | 289 | } |
290 | 290 | ||
291 | fflush(NULL); /* flush all streams */ | 291 | fflush_all(); |
292 | pid = vfork(); /* NOMMU-friendly */ | 292 | pid = vfork(); /* NOMMU-friendly */ |
293 | if (pid < 0) { | 293 | if (pid < 0) { |
294 | free(ts); | 294 | free(ts); |
@@ -331,7 +331,7 @@ make_new_session( | |||
331 | /*termbuf.c_lflag &= ~ICANON;*/ | 331 | /*termbuf.c_lflag &= ~ICANON;*/ |
332 | tcsetattr_stdin_TCSANOW(&termbuf); | 332 | tcsetattr_stdin_TCSANOW(&termbuf); |
333 | 333 | ||
334 | /* Uses FILE-based I/O to stdout, but does fflush(stdout), | 334 | /* Uses FILE-based I/O to stdout, but does fflush_all(), |
335 | * so should be safe with vfork. | 335 | * so should be safe with vfork. |
336 | * I fear, though, that some users will have ridiculously big | 336 | * I fear, though, that some users will have ridiculously big |
337 | * issue files, and they may block writing to fd 1, | 337 | * issue files, and they may block writing to fd 1, |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 7284f0022..fa45db98a 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -815,7 +815,7 @@ int traceroute_main(int argc, char **argv) | |||
815 | 815 | ||
816 | if (!first && pausemsecs > 0) | 816 | if (!first && pausemsecs > 0) |
817 | usleep(pausemsecs * 1000); | 817 | usleep(pausemsecs * 1000); |
818 | fflush(stdout); | 818 | fflush_all(); |
819 | 819 | ||
820 | t1 = monotonic_us(); | 820 | t1 = monotonic_us(); |
821 | send_probe(++seq, ttl); | 821 | send_probe(++seq, ttl); |
diff --git a/procps/top.c b/procps/top.c index 252f6f74b..79915697c 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -632,7 +632,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
632 | } | 632 | } |
633 | /* printf(" %d", hist_iterations); */ | 633 | /* printf(" %d", hist_iterations); */ |
634 | bb_putchar(OPT_BATCH_MODE ? '\n' : '\r'); | 634 | bb_putchar(OPT_BATCH_MODE ? '\n' : '\r'); |
635 | fflush(stdout); | 635 | fflush_all(); |
636 | } | 636 | } |
637 | #undef UPSCALE | 637 | #undef UPSCALE |
638 | #undef SHOW_STAT | 638 | #undef SHOW_STAT |
@@ -856,7 +856,7 @@ static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) | |||
856 | s++; | 856 | s++; |
857 | } | 857 | } |
858 | bb_putchar(OPT_BATCH_MODE ? '\n' : '\r'); | 858 | bb_putchar(OPT_BATCH_MODE ? '\n' : '\r'); |
859 | fflush(stdout); | 859 | fflush_all(); |
860 | #undef HDR_STR | 860 | #undef HDR_STR |
861 | #undef MIN_WIDTH | 861 | #undef MIN_WIDTH |
862 | } | 862 | } |
diff --git a/procps/watch.c b/procps/watch.c index 5fd051072..f446ec918 100644 --- a/procps/watch.c +++ b/procps/watch.c | |||
@@ -64,7 +64,7 @@ int watch_main(int argc UNUSED_PARAM, char **argv) | |||
64 | 64 | ||
65 | puts(header); | 65 | puts(header); |
66 | } | 66 | } |
67 | fflush(stdout); | 67 | fflush_all(); |
68 | // TODO: 'real' watch pipes cmd's output to itself | 68 | // TODO: 'real' watch pipes cmd's output to itself |
69 | // and does not allow it to overflow the screen | 69 | // and does not allow it to overflow the screen |
70 | // (taking into account linewrap!) | 70 | // (taking into account linewrap!) |
diff --git a/runit/svlogd.c b/runit/svlogd.c index b7fd15262..9a00fadee 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -1152,7 +1152,7 @@ int svlogd_main(int argc, char **argv) | |||
1152 | /* Move unprocessed data to the front of line */ | 1152 | /* Move unprocessed data to the front of line */ |
1153 | memmove((timestamp ? line+26 : line), lineptr, stdin_cnt); | 1153 | memmove((timestamp ? line+26 : line), lineptr, stdin_cnt); |
1154 | } | 1154 | } |
1155 | fflush(NULL);//// | 1155 | fflush_all();//// |
1156 | } | 1156 | } |
1157 | 1157 | ||
1158 | for (i = 0; i < dirn; ++i) { | 1158 | for (i = 0; i < dirn; ++i) { |
diff --git a/scripts/echo.c b/scripts/echo.c index 9e591c4d5..85a8aa913 100644 --- a/scripts/echo.c +++ b/scripts/echo.c | |||
@@ -187,7 +187,7 @@ int main(int argc, char **argv) | |||
187 | putchar('\n'); | 187 | putchar('\n'); |
188 | } | 188 | } |
189 | ret: | 189 | ret: |
190 | return fflush(stdout); | 190 | return fflush_all(); |
191 | } | 191 | } |
192 | 192 | ||
193 | /*- | 193 | /*- |
diff --git a/selinux/setfiles.c b/selinux/setfiles.c index aabc37137..0a4643784 100644 --- a/selinux/setfiles.c +++ b/selinux/setfiles.c | |||
@@ -286,7 +286,7 @@ static int restore(const char *file) | |||
286 | if (count == 0) | 286 | if (count == 0) |
287 | bb_putchar('\n'); | 287 | bb_putchar('\n'); |
288 | bb_putchar('*'); | 288 | bb_putchar('*'); |
289 | fflush(stdout); | 289 | fflush_all(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
diff --git a/shell/ash.c b/shell/ash.c index 481b84138..6b985ad7c 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -389,16 +389,7 @@ static void | |||
389 | flush_stdout_stderr(void) | 389 | flush_stdout_stderr(void) |
390 | { | 390 | { |
391 | INT_OFF; | 391 | INT_OFF; |
392 | fflush(stdout); | 392 | fflush_all(); |
393 | fflush(stderr); | ||
394 | INT_ON; | ||
395 | } | ||
396 | |||
397 | static void | ||
398 | flush_stderr(void) | ||
399 | { | ||
400 | INT_OFF; | ||
401 | fflush(stderr); | ||
402 | INT_ON; | 393 | INT_ON; |
403 | } | 394 | } |
404 | 395 | ||
@@ -451,7 +442,7 @@ static void | |||
451 | out2str(const char *p) | 442 | out2str(const char *p) |
452 | { | 443 | { |
453 | outstr(p, stderr); | 444 | outstr(p, stderr); |
454 | flush_stderr(); | 445 | flush_stdout_stderr(); |
455 | } | 446 | } |
456 | 447 | ||
457 | 448 | ||
@@ -8184,7 +8175,7 @@ evaltree(union node *n, int flags) | |||
8184 | default: | 8175 | default: |
8185 | #if DEBUG | 8176 | #if DEBUG |
8186 | out1fmt("Node type = %d\n", n->type); | 8177 | out1fmt("Node type = %d\n", n->type); |
8187 | fflush(stdout); | 8178 | fflush_all(); |
8188 | break; | 8179 | break; |
8189 | #endif | 8180 | #endif |
8190 | case NNOT: | 8181 | case NNOT: |
@@ -9101,7 +9092,7 @@ evalcommand(union node *cmd, int flags) | |||
9101 | for (;;) { | 9092 | for (;;) { |
9102 | find_command(argv[0], &cmdentry, cmd_flag, path); | 9093 | find_command(argv[0], &cmdentry, cmd_flag, path); |
9103 | if (cmdentry.cmdtype == CMDUNKNOWN) { | 9094 | if (cmdentry.cmdtype == CMDUNKNOWN) { |
9104 | flush_stderr(); | 9095 | flush_stdout_stderr(); |
9105 | status = 127; | 9096 | status = 127; |
9106 | goto bail; | 9097 | goto bail; |
9107 | } | 9098 | } |
diff --git a/shell/hush.c b/shell/hush.c index 1187cbe8f..891d87be7 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -1206,7 +1206,7 @@ static void hush_exit(int exitcode) | |||
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | #if ENABLE_HUSH_JOB | 1208 | #if ENABLE_HUSH_JOB |
1209 | fflush(NULL); /* flush all streams */ | 1209 | fflush_all(); |
1210 | sigexit(- (exitcode & 0xff)); | 1210 | sigexit(- (exitcode & 0xff)); |
1211 | #else | 1211 | #else |
1212 | exit(exitcode); | 1212 | exit(exitcode); |
@@ -1679,7 +1679,7 @@ static void get_user_input(struct in_str *i) | |||
1679 | do { | 1679 | do { |
1680 | G.flag_SIGINT = 0; | 1680 | G.flag_SIGINT = 0; |
1681 | fputs(prompt_str, stdout); | 1681 | fputs(prompt_str, stdout); |
1682 | fflush(stdout); | 1682 | fflush_all(); |
1683 | G.user_input_buf[0] = r = fgetc(i->file); | 1683 | G.user_input_buf[0] = r = fgetc(i->file); |
1684 | /*G.user_input_buf[1] = '\0'; - already is and never changed */ | 1684 | /*G.user_input_buf[1] = '\0'; - already is and never changed */ |
1685 | //do we need check_and_run_traps(0)? (maybe only if stdin) | 1685 | //do we need check_and_run_traps(0)? (maybe only if stdin) |
@@ -3220,7 +3220,7 @@ static void exec_function(char ***to_free, | |||
3220 | G.global_argc = n; | 3220 | G.global_argc = n; |
3221 | /* On MMU, funcp->body is always non-NULL */ | 3221 | /* On MMU, funcp->body is always non-NULL */ |
3222 | n = run_list(funcp->body); | 3222 | n = run_list(funcp->body); |
3223 | fflush(NULL); | 3223 | fflush_all(); |
3224 | _exit(n); | 3224 | _exit(n); |
3225 | # else | 3225 | # else |
3226 | re_execute_shell(to_free, | 3226 | re_execute_shell(to_free, |
@@ -3307,7 +3307,7 @@ static void exec_builtin(char ***to_free, | |||
3307 | { | 3307 | { |
3308 | #if BB_MMU | 3308 | #if BB_MMU |
3309 | int rcode = x->function(argv); | 3309 | int rcode = x->function(argv); |
3310 | fflush(NULL); | 3310 | fflush_all(); |
3311 | _exit(rcode); | 3311 | _exit(rcode); |
3312 | #else | 3312 | #else |
3313 | /* On NOMMU, we must never block! | 3313 | /* On NOMMU, we must never block! |
@@ -3933,7 +3933,7 @@ static NOINLINE int run_pipe(struct pipe *pi) | |||
3933 | debug_printf_exec(": builtin '%s' '%s'...\n", | 3933 | debug_printf_exec(": builtin '%s' '%s'...\n", |
3934 | x->cmd, argv_expanded[1]); | 3934 | x->cmd, argv_expanded[1]); |
3935 | rcode = x->function(argv_expanded) & 0xff; | 3935 | rcode = x->function(argv_expanded) & 0xff; |
3936 | fflush(NULL); | 3936 | fflush_all(); |
3937 | } | 3937 | } |
3938 | #if ENABLE_HUSH_FUNCTIONS | 3938 | #if ENABLE_HUSH_FUNCTIONS |
3939 | else { | 3939 | else { |
@@ -7136,7 +7136,7 @@ static int FAST_FUNC builtin_export(char **argv) | |||
7136 | putchar('\n'); | 7136 | putchar('\n'); |
7137 | #endif | 7137 | #endif |
7138 | } | 7138 | } |
7139 | /*fflush(stdout); - done after each builtin anyway */ | 7139 | /*fflush_all(); - done after each builtin anyway */ |
7140 | } | 7140 | } |
7141 | return EXIT_SUCCESS; | 7141 | return EXIT_SUCCESS; |
7142 | } | 7142 | } |
@@ -7181,7 +7181,7 @@ static int FAST_FUNC builtin_trap(char **argv) | |||
7181 | printf(" %s\n", get_signame(i)); | 7181 | printf(" %s\n", get_signame(i)); |
7182 | } | 7182 | } |
7183 | } | 7183 | } |
7184 | /*fflush(stdout); - done after each builtin anyway */ | 7184 | /*fflush_all(); - done after each builtin anyway */ |
7185 | return EXIT_SUCCESS; | 7185 | return EXIT_SUCCESS; |
7186 | } | 7186 | } |
7187 | 7187 | ||
diff --git a/sysklogd/logread.c b/sysklogd/logread.c index 603a3776c..932bbecbb 100644 --- a/sysklogd/logread.c +++ b/sysklogd/logread.c | |||
@@ -135,7 +135,7 @@ int logread_main(int argc UNUSED_PARAM, char **argv) | |||
135 | } else { /* logread -f */ | 135 | } else { /* logread -f */ |
136 | if (cur == shbuf_tail) { | 136 | if (cur == shbuf_tail) { |
137 | sem_up(log_semid); | 137 | sem_up(log_semid); |
138 | fflush(stdout); | 138 | fflush_all(); |
139 | sleep(1); /* TODO: replace me with a sleep_on */ | 139 | sleep(1); /* TODO: replace me with a sleep_on */ |
140 | continue; | 140 | continue; |
141 | } | 141 | } |
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index cdd306031..cc9eec22d 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c | |||
@@ -341,7 +341,7 @@ static int ask(const char *string, int def) | |||
341 | } | 341 | } |
342 | printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); | 342 | printf(def ? "%s (y/n)? " : "%s (n/y)? ", string); |
343 | for (;;) { | 343 | for (;;) { |
344 | fflush(NULL); | 344 | fflush_all(); |
345 | c = getchar(); | 345 | c = getchar(); |
346 | if (c == EOF) { | 346 | if (c == EOF) { |
347 | if (!def) | 347 | if (!def) |
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index cf757610b..8819cee4e 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c | |||
@@ -505,7 +505,7 @@ static void alarm_intr(int alnum UNUSED_PARAM) | |||
505 | if (!G.currently_testing) | 505 | if (!G.currently_testing) |
506 | return; | 506 | return; |
507 | printf("%d ...", G.currently_testing); | 507 | printf("%d ...", G.currently_testing); |
508 | fflush(stdout); | 508 | fflush_all(); |
509 | } | 509 | } |
510 | 510 | ||
511 | static void check_blocks(void) | 511 | static void check_blocks(void) |
diff --git a/util-linux/more.c b/util-linux/more.c index 9ac4dd8e3..555f033d4 100644 --- a/util-linux/more.c +++ b/util-linux/more.c | |||
@@ -114,7 +114,7 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
114 | (int) (ftello(file)*100 / st.st_size), | 114 | (int) (ftello(file)*100 / st.st_size), |
115 | st.st_size); | 115 | st.st_size); |
116 | } | 116 | } |
117 | fflush(stdout); | 117 | fflush_all(); |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * We've just displayed the "--More--" prompt, so now we need | 120 | * We've just displayed the "--More--" prompt, so now we need |
@@ -189,7 +189,7 @@ int more_main(int argc UNUSED_PARAM, char **argv) | |||
189 | putchar(c); | 189 | putchar(c); |
190 | } | 190 | } |
191 | fclose(file); | 191 | fclose(file); |
192 | fflush(stdout); | 192 | fflush_all(); |
193 | } while (*argv && *++argv); | 193 | } while (*argv && *++argv); |
194 | end: | 194 | end: |
195 | setTermSettings(cin_fileno, &initial_settings); | 195 | setTermSettings(cin_fileno, &initial_settings); |
diff --git a/util-linux/rtcwake.c b/util-linux/rtcwake.c index f90f73ced..049f699f5 100644 --- a/util-linux/rtcwake.c +++ b/util-linux/rtcwake.c | |||
@@ -172,7 +172,7 @@ int rtcwake_main(int argc UNUSED_PARAM, char **argv) | |||
172 | 172 | ||
173 | sync(); | 173 | sync(); |
174 | printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time)); | 174 | printf("wakeup from \"%s\" at %s", suspend, ctime(&alarm_time)); |
175 | fflush(NULL); | 175 | fflush_all(); |
176 | usleep(10 * 1000); | 176 | usleep(10 * 1000); |
177 | 177 | ||
178 | if (strcmp(suspend, "on")) | 178 | if (strcmp(suspend, "on")) |