Fix two bugs:
[pintos-anon] / src / utils / pintos
index b18693b776f6bf1679ded0b590f1c690c9500114..ccf10377641baf04ee31ad679e4df626b8f16dcc 100755 (executable)
@@ -492,7 +492,9 @@ config.version = 6
 guestOS = "linux"
 floppy0.present = FALSE
 memsize = $mem
+EOF
 
+    print VMX <<EOF if $serial;
 serial0.present = TRUE
 serial0.fileType = "file"
 serial0.fileName = "pintos.out"
@@ -702,7 +704,13 @@ 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
@@ -748,7 +756,7 @@ sub xsystem {
 sub relay_signal {
     my ($pid, $signal, $cleanup) = @_;
     kill $signal, $pid;
-    File::Temp::cleanup();
+    eval { File::Temp::cleanup() };    # Not defined in old File::Temp.
     &$cleanup ();
     $SIG{$signal} = 'DEFAULT';
     kill $signal, getpid ();