mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
* 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
1 changed files with 12 additions and 6 deletions
|
@ -121,10 +121,6 @@ sub start {
|
|||
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 start {
|
|||
|
||||
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 @@ sub start {
|
|||
$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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue