Author: eelco
Date: 2010-06-18 15:30:36 +0000 (Fri, 18 Jun 2010)
New Revision: 22328

You can view the changes in this commit at:
   https://svn.nixos.org/viewvc/nix?rev=22328&view=rev

Modified:
   nixos/branches/boot-order/lib/test-driver/Machine.pm

Log:
* Intercept SIGCHLD to prevent accept() from waiting forever if QEMU
  dies before connecting to the monitor.


Changes:

Modified: nixos/branches/boot-order/lib/test-driver/Machine.pm
===================================================================
--- nixos/branches/boot-order/lib/test-driver/Machine.pm        2010-06-18 
15:22:59 UTC (rev 22327)
+++ nixos/branches/boot-order/lib/test-driver/Machine.pm        2010-06-18 
15:30:36 UTC (rev 22328)
@@ -121,10 +121,6 @@
         die;
     }
 
-    # Wait until QEMU connects to the monitor.
-    accept($self->{monitor}, $monitorS) or die;
-    $self->waitForMonitorPrompt;
-
     # Process serial line output.
     close $serialC;
 
@@ -132,9 +128,9 @@
 
     sub processSerialOutput {
         my ($self, $serialP) = @_;
-        $/ = "\r\n";
         while (<$serialP>) {
             chomp;
+            s/\r$//;
             print STDERR $self->name, "# $_\n";
             $self->{connectedQueue}->enqueue(1) if $_ eq "===UP===";
         }
@@ -142,7 +138,17 @@
         $self->{connectedQueue}->enqueue(1);
     }
 
-    $self->log("vm running as pid $pid");
+    # Wait until QEMU connects to the monitor.
+    eval {
+        local $SIG{CHLD} = sub { die "QEMU died prematurely\n"; };
+        accept($self->{monitor}, $monitorS) or die;
+    };
+    die "$@" if $@;
+    
+    $self->waitForMonitorPrompt;
+
+    $self->log("QEMU running (pid $pid)");
+    
     $self->{pid} = $pid;
     $self->{booted} = 1;
 }

_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to