]> git.proxmox.com Git - qemu-server.git/commitdiff
kill socat if we do not get any connection within $timeout seconds
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 25 Jun 2013 12:34:59 +0000 (14:34 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 25 Jun 2013 12:34:59 +0000 (14:34 +0200)
PVE/API2/Qemu.pm

index 5d9cbb92cfec0f1be4ba380dd1980ae79374dfeb..46228cf2dfcc10772c332292c9691b0d978665d0 100644 (file)
@@ -1411,7 +1411,13 @@ __PACKAGE__->register_method({
                }
            };
            
-           eval { PVE::Tools::run_command($cmd, errfunc => $parser, outfunc => sub{}); };
+           eval { 
+               # kill socat if we do not get any connection within $timeout seconds
+               local $SIG{ALRM} = sub { die "got timeout\n" if $conn_count <= 0; };
+               alarm($timeout);
+
+               PVE::Tools::run_command($cmd, errfunc => $parser, outfunc => sub{}); 
+           };
            if (my $err = $@) {
                die $err if $err !~ m/client exit$/;
            }