changeset 640:85fc06bd63c4 0.4.0

Workaround longstanding glibc/ld bug, ala http://sources.redhat.com/bugzilla/show_bug.cgi?id=3400, which prevents "./toybox | wc" from producing any output when toybox was statically linked.
author Rob Landley <rob@landley.net>
date Mon, 23 Jul 2012 23:38:34 -0500
parents 3c591e7a367d
children 94f189961631
files lib/lib.c main.c
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib/lib.c	Sat Jul 21 23:58:40 2012 -0500
+++ b/lib/lib.c	Mon Jul 23 23:38:34 2012 -0500
@@ -160,7 +160,7 @@
 
 void xputc(char c)
 {
-	if (EOF == fputc(c, stdout)) perror_exit("write");
+	if (EOF == fputc(c, stdout) || fflush(stdout)) perror_exit("write");
 }
 
 void xflush(void)
--- a/main.c	Sat Jul 21 23:58:40 2012 -0500
+++ b/main.c	Mon Jul 23 23:38:34 2012 -0500
@@ -133,12 +133,12 @@
 			}
 			len += printf("%s ",toy_list[i].name);
 			if (len>65) {
-				putchar('\n');
+				xputc('\n');
 				len=0;
 			}
 		}
 	}
-	putchar('\n');
+	xputc('\n');
 }
 
 int main(int argc, char *argv[])