X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Futils%2Fpintos;h=13d7e5436fbe77a79d18ac1d81b02083214fa8de;hb=b8632191cf88da4debca435c1ac834ba17428b01;hp=856ebfa473ac270c70858547aabef498d7360f8d;hpb=f14d80c05e67af1545779f038d9f47dec2188fc3;p=pintos-anon diff --git a/src/utils/pintos b/src/utils/pintos index 856ebfa..13d7e54 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -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) {