Small patch to "clear" to add flush

Denys Vlasenko vda.linux at googlemail.com
Wed Dec 26 13:21:15 PST 2007


On Wednesday 26 December 2007 20:37, JoSH Lehan wrote:
> Hello.
>
> I have made a small one-line patch to the "clear" applet, to ensure
> that output gets flushed.
> It's a workaround for that well-known bug in glibc:
>
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=3400
>
> Also, I changed the clear string to output 7 characters, not 6, just
> to be correct with respect to the traditional terminal codes.
>
> Here's the patch:
>
> diff -urN busybox-1.8.2-OLD/console-tools/clear.c
> busybox-1.8.2/console-tools/clear.c
> --- busybox-1.8.2-OLD/console-tools/clear.c	2007-11-09 17:40:49.000000000
> -0800 +++ busybox-1.8.2/console-tools/clear.c	2007-12-20 15:51:30.000000000
> -0800 @@ -15,5 +15,5 @@
>  int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
>  int clear_main(int argc, char **argv)
>  {
> -	return printf("\033[H\033[J") != 6;
> +	return ((printf("\033[H\033[2J") != 7) || fflush(NULL));
>  }
>
> Comments/suggestions?

This is not a bug in busybox. You cannot even build busybox statically
against glibc without getting a warning. Did you *read* a warning?
Hint: it says what you need to do...
--
vda


More information about the busybox mailing list