* Intercept SIGCHLD to prevent accept() from waiting forever if QEMU
dies before connecting to the monitor. svn path=/nixos/branches/boot-order/; revision=22328
This commit is contained in:
parent
ac22e5369f
commit
cf7e902283
@ -121,10 +121,6 @@ sub start {
|
|||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wait until QEMU connects to the monitor.
|
|
||||||
accept($self->{monitor}, $monitorS) or die;
|
|
||||||
$self->waitForMonitorPrompt;
|
|
||||||
|
|
||||||
# Process serial line output.
|
# Process serial line output.
|
||||||
close $serialC;
|
close $serialC;
|
||||||
|
|
||||||
@ -132,9 +128,9 @@ sub start {
|
|||||||
|
|
||||||
sub processSerialOutput {
|
sub processSerialOutput {
|
||||||
my ($self, $serialP) = @_;
|
my ($self, $serialP) = @_;
|
||||||
$/ = "\r\n";
|
|
||||||
while (<$serialP>) {
|
while (<$serialP>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
s/\r$//;
|
||||||
print STDERR $self->name, "# $_\n";
|
print STDERR $self->name, "# $_\n";
|
||||||
$self->{connectedQueue}->enqueue(1) if $_ eq "===UP===";
|
$self->{connectedQueue}->enqueue(1) if $_ eq "===UP===";
|
||||||
}
|
}
|
||||||
@ -142,7 +138,17 @@ sub start {
|
|||||||
$self->{connectedQueue}->enqueue(1);
|
$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->{pid} = $pid;
|
||||||
$self->{booted} = 1;
|
$self->{booted} = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user