Fix stupidity in last check-in.
[pintos-anon] / src / utils / pintos
index 856ebfa473ac270c70858547aabef498d7360f8d..13d7e5436fbe77a79d18ac1d81b02083214fa8de 100755 (executable)
@@ -701,12 +701,19 @@ sub xsystem {
            # Filter output.
            my ($buf) = "";
            my ($boots) = 0;
-           while (waitpid ($pid, WNOHANG) == 0) {
+           local ($|) = 1;
+           for (;;) {
+               if (waitpid ($pid, WNOHANG) != 0) {
+                   # Subprocess died.  Pass through any remaining data.
+                   print $buf while sysread ($in, $buf, 4096) > 0;
+                   last;
+               }
+
                # Read and print out pipe data.
                my ($len) = length ($buf);
                waitpid ($pid, 0), last
                  if sysread ($in, $buf, 4096, $len) <= 0;
-               print STDOUT substr ($buf, $len);
+               print substr ($buf, $len);
 
                # Remove full lines from $buf and scan them for keywords.
                while ((my $idx = index ($buf, "\n")) >= 0) {