diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/bb_askpass.c | 4 | ||||
-rw-r--r-- | libbb/info_msg.c | 2 | ||||
-rw-r--r-- | libbb/lineedit.c | 14 | ||||
-rw-r--r-- | libbb/login.c | 4 | ||||
-rw-r--r-- | libbb/verror_msg.c | 6 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 2 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 11 |
7 files changed, 20 insertions, 23 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c index 073175c..f9b918c 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) } fputs(prompt, stdout); - fflush(stdout); + fflush_all(); ret = NULL; /* On timeout or Ctrl-C, read will hopefully be interrupted, * and we return NULL */ @@ -77,6 +77,6 @@ char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt) tcsetattr_stdin_TCSANOW(&oldtio); bb_putchar('\n'); - fflush(stdout); + fflush_all(); return ret; } diff --git a/libbb/info_msg.c b/libbb/info_msg.c index 8b8a1fc..5f375d4 100644 --- a/libbb/info_msg.c +++ b/libbb/info_msg.c @@ -44,7 +44,7 @@ void FAST_FUNC bb_info_msg(const char *s, ...) if (ENABLE_FEATURE_SYSLOG && (logmode & LOGMODE_SYSLOG)) syslog(LOG_INFO, "%s", msg); if (logmode & LOGMODE_STDIO) { - fflush(stdout); + fflush_all(); /* used = strlen(msg); - must be true already */ msg[used++] = '\n'; full_write(STDOUT_FILENO, msg, used); diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 0f7ab8c..a997257 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -373,7 +373,7 @@ static void input_backward(unsigned num) static void put_prompt(void) { out1str(cmdedit_prompt); - fflush(NULL); + fflush_all(); #if ENABLE_FEATURE_EDITING_ASK_TERMINAL { /* Ask terminal where is the cursor now. @@ -411,7 +411,7 @@ static void put_prompt(void) if (safe_poll(&pfd, 1, 0) == 0) { S.sent_ESC_br6n = 1; out1str("\033" "[6n"); - fflush(NULL); /* make terminal see it ASAP! */ + fflush_all(); /* make terminal see it ASAP! */ } } #endif @@ -1636,7 +1636,7 @@ static void cmdedit_setwidth(unsigned w, int redraw_flg) int new_y = (cursor + cmdedit_prmt_len) / w; /* redraw */ redraw((new_y >= cmdedit_y ? new_y : cmdedit_y), command_len - cursor); - fflush(NULL); + fflush_all(); } } @@ -1748,7 +1748,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li ) { /* Happens when e.g. stty -echo was run before */ parse_and_put_prompt(prompt); - /* fflush(stdout); - done by parse_and_put_prompt */ + /* fflush_all(); - done by parse_and_put_prompt */ if (fgets(command, maxsize, stdin) == NULL) len = -1; /* EOF or error */ else @@ -1841,7 +1841,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li }; int32_t ic, ic_raw; - fflush(NULL); + fflush_all(); ic = ic_raw = lineedit_read_key(read_key_buffer); #if ENABLE_FEATURE_EDITING_VI @@ -2245,7 +2245,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li tcsetattr_stdin_TCSANOW(&initial_settings); /* restore SIGWINCH handler */ signal(SIGWINCH, previous_SIGWINCH_handler); - fflush(NULL); + fflush_all(); len = command_len; DEINIT_S(); @@ -2259,7 +2259,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize) { fputs(prompt, stdout); - fflush(NULL); + fflush_all(); fgets(command, maxsize, stdin); return strlen(command); } diff --git a/libbb/login.c b/libbb/login.c index 07247a8..740c588 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) fputs(outbuf, stdout); } fclose(fp); - fflush(stdout); + fflush_all(); } void FAST_FUNC print_login_prompt(void) @@ -94,7 +94,7 @@ void FAST_FUNC print_login_prompt(void) fputs(hostname, stdout); fputs(LOGIN, stdout); - fflush(stdout); + fflush_all(); free(hostname); } diff --git a/libbb/verror_msg.c b/libbb/verror_msg.c index 506b906..70f792f 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) } if (logmode & LOGMODE_STDIO) { - fflush(stdout); + fflush_all(); full_write(STDERR_FILENO, msg, used); } if (logmode & LOGMODE_SYSLOG) { @@ -125,8 +125,8 @@ void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) iov[1].iov_len = 2; /*iov[2].iov_base = msgc;*/ /*iov[2].iov_len = used;*/ - fflush(stdout); - writev(2, iov, 3); + fflush_all(); + writev(STDERR_FILENO, iov, 3); } if (logmode & LOGMODE_SYSLOG) { syslog(LOG_ERR, "%s", msgc); diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 27efb0e..9be9017 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c @@ -25,7 +25,7 @@ pid_t FAST_FUNC spawn(char **argv) volatile int failed; pid_t pid; -// Ain't it a good place to fflush(NULL)? + fflush_all(); /* Be nice to nommu machines. */ failed = 0; diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 241887a..644134a 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c @@ -255,12 +255,9 @@ void FAST_FUNC die_if_ferror_stdout(void) die_if_ferror(stdout, bb_msg_standard_output); } -// Die with an error message if we have trouble flushing stdout. -void FAST_FUNC xfflush_stdout(void) +int FAST_FUNC fflush_all(void) { - if (fflush(stdout)) { - bb_perror_msg_and_die(bb_msg_standard_output); - } + return fflush(NULL); } @@ -276,9 +273,9 @@ int FAST_FUNC bb_putchar(int ch) * then close that file. */ void FAST_FUNC xprint_and_close_file(FILE *file) { - fflush(stdout); + fflush_all(); // copyfd outputs error messages for us. - if (bb_copyfd_eof(fileno(file), 1) == -1) + if (bb_copyfd_eof(fileno(file), STDOUT_FILENO) == -1) xfunc_die(); fclose(file); |