Flush stdout, stderr before forking. From Richard Purdie. Thanks!
[oweals/opkg-lede.git] / libbb / gz_open.c
index 7c7c722d3cb640d4f768fa7ce2432ac4aff8045a..40f741f4770de11754082fd1673f79a3e7afb399 100644 (file)
@@ -38,6 +38,12 @@ gz_open(FILE *compressed_file, int *pid)
                perror_msg("pipe");
                return(NULL);
        }
+
+    /* If we don't flush, we end up with two copies of anything pending, 
+       one from the parent, one from the child */
+    fflush(stdout);
+    fflush(stderr);
+
        if ((*pid = fork()) == -1) {
                perror_msg("fork");
                return(NULL);