X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Futils%2Fpintos;h=13d7e5436fbe77a79d18ac1d81b02083214fa8de;hb=b8632191cf88da4debca435c1ac834ba17428b01;hp=079ab5a34d22e8970a631203acdf6913e2a7a4fe;hpb=aeed0081c47374eab414d73e03ed2eab4723ac9f;p=pintos-anon diff --git a/src/utils/pintos b/src/utils/pintos index 079ab5a..13d7e54 100755 --- a/src/utils/pintos +++ b/src/utils/pintos @@ -703,7 +703,7 @@ sub xsystem { my ($boots) = 0; local ($|) = 1; for (;;) { - if (waitpid ($pid, WNOHANG) == 0) { + if (waitpid ($pid, WNOHANG) != 0) { # Subprocess died. Pass through any remaining data. print $buf while sysread ($in, $buf, 4096) > 0; last; @@ -711,7 +711,8 @@ sub xsystem { # Read and print out pipe data. my ($len) = length ($buf); - last if sysread ($in, $buf, 4096, $len) <= 0; + waitpid ($pid, 0), last + if sysread ($in, $buf, 4096, $len) <= 0; print substr ($buf, $len); # Remove full lines from $buf and scan them for keywords. @@ -730,8 +731,9 @@ sub xsystem { } } } + } else { + waitpid ($pid, 0); } - waitpid ($pid, 0); alarm (0); &$cleanup ();