X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Futils%2Fpintos;h=079ab5a34d22e8970a631203acdf6913e2a7a4fe;hb=94e3568f3303b757f9e4133524b647163792662d;hp=b18693b776f6bf1679ded0b590f1c690c9500114;hpb=c1589ebc0b6ea34d608af61bad80979abbaeb9fc;p=pintos-anon diff --git a/src/utils/pintos b/src/utils/pintos index b18693b..079ab5a 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -702,11 +702,16 @@ sub xsystem { my ($buf) = ""; my ($boots) = 0; local ($|) = 1; - while (waitpid ($pid, WNOHANG) == 0) { + 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; + last if sysread ($in, $buf, 4096, $len) <= 0; print substr ($buf, $len); # Remove full lines from $buf and scan them for keywords. @@ -725,9 +730,8 @@ sub xsystem { } } } - } else { - waitpid ($pid, 0); } + waitpid ($pid, 0); alarm (0); &$cleanup ();