[patch] coreutils/printf.c

Denys Vlasenko vda.linux at googlemail.com
Sun Jun 1 22:35:59 UTC 2008


On Sunday 01 June 2008 21:18, Cristian Ionescu-Idbohrn wrote:


 int printf_main(int argc ATTRIBUTE_UNUSED, char **argv)
 {
        char *format;
        char **argv2;

+       /* We must check that stdout is not closed.
+        * The reason for this is highly non-obvious.
+        * echo_main is used from shell. Shell must correctly handle "echo foo"
+        * if stdout is closed. With stdio, output gets shoveled into
+        * stdout buffer, and even fflush cannot clear it out. It seems that
+        * even if libc receives EBADF on write attempts, it feels determined
+        * to output data no matter what. So it will try later,
+        * and possibly will clobber future output. Not good. */
+       if (dup2(1, 1) != 1)
+               return -1;

copy-paste error in comments.

Also with attached .config:

shell/lib.a(ash.o):(.rodata.builtintab+0xc4): undefined reference to `printf_main'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1

I fixed it up and applied to svn. Thanks.

P.S. If it's not too difficult, please send patches which are applyable
with patch -p1 (i.e. kernel-style patches).
Currently you are sending -p0 patches.
--
vda

-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.bz2
Type: application/x-bzip2
Size: 4633 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080602/3b65ec57/attachment-0002.bin 


More information about the busybox mailing list