*: do not assign to stdout/stderr, it's not portable.
Based on patch by Aaron Carroll <xaaronc@gmail.com> function old new delta time_main 1062 1052 -10 cpio_main 563 549 -14 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
1ee5afdce2
commit
c066472b0c
@ -354,10 +354,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (*cpio_fmt != 'n') /* we _require_ "-H newc" */
|
if (*cpio_fmt != 'n') /* we _require_ "-H newc" */
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
if (opt & CPIO_OPT_FILE) {
|
if (opt & CPIO_OPT_FILE) {
|
||||||
fclose(stdout);
|
xmove_fd(xopen3(cpio_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666), STDOUT_FILENO);
|
||||||
stdout = fopen_for_write(cpio_filename);
|
|
||||||
/* Paranoia: I don't trust libc that much */
|
|
||||||
xdup2(fileno(stdout), STDOUT_FILENO);
|
|
||||||
}
|
}
|
||||||
dump:
|
dump:
|
||||||
return cpio_o();
|
return cpio_o();
|
||||||
|
@ -263,10 +263,7 @@ int FAST_FUNC fflush_all(void)
|
|||||||
|
|
||||||
int FAST_FUNC bb_putchar(int ch)
|
int FAST_FUNC bb_putchar(int ch)
|
||||||
{
|
{
|
||||||
/* time.c needs putc(ch, stdout), not putchar(ch).
|
return putchar(ch);
|
||||||
* it does "stdout = stderr;", but then glibc's putchar()
|
|
||||||
* doesn't work as expected. bad glibc, bad */
|
|
||||||
return putc(ch, stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Die with an error message if we can't copy an entire FILE* to stdout,
|
/* Die with an error message if we can't copy an entire FILE* to stdout,
|
||||||
|
@ -414,9 +414,7 @@ int time_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
run_command(argv, &res);
|
run_command(argv, &res);
|
||||||
|
|
||||||
/* Cheat. printf's are shorter :) */
|
/* Cheat. printf's are shorter :) */
|
||||||
/* (but see bb_putchar() body for additional wrinkle!) */
|
xdup2(STDERR_FILENO, STDOUT_FILENO);
|
||||||
xdup2(2, 1); /* just in case libc does something silly :( */
|
|
||||||
stdout = stderr;
|
|
||||||
summarize(output_format, argv, &res);
|
summarize(output_format, argv, &res);
|
||||||
|
|
||||||
if (WIFSTOPPED(res.waitstatus))
|
if (WIFSTOPPED(res.waitstatus))
|
||||||
|
Loading…
Reference in New Issue
Block a user