]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
wait_for_vnc_port: die if port did not get ready
[pve-common.git] / src / PVE / Tools.pm
index bd99914c58e780d4eba4204eb500e739ae000b15..2c64f6ac33206791a5e70b038b49b76fa71b13dd 100644 (file)
@@ -150,7 +150,7 @@ sub lock_file_full {
            or die "can't open file - $!\n";
 
        if (!flock($fh, $mode|LOCK_NB)) {
-           print STDERR "trying to acquire lock...";
+           print STDERR "trying to acquire lock...\n";
            my $success;
            while(1) {
                $success = flock($fh, $mode);
@@ -812,7 +812,7 @@ sub wait_for_vnc_port {
        usleep($sleeptime);
     }
 
-    return undef;
+    die "Timeout while waiting for port '$port' to get ready!\n";
 }
 
 sub next_unused_port {
@@ -945,7 +945,11 @@ sub run_fork_with_timeout {
        $error = $child_res->{error};
     };
     eval {
-       run_with_timeout($timeout, $readvalues);
+       if (defined($timeout)) {
+           run_with_timeout($timeout, $readvalues);
+       } else {
+           $readvalues->();
+       }
     };
     warn $@ if $@;
     $pipe_out->close();
@@ -959,6 +963,11 @@ sub run_fork_with_timeout {
     return $res;
 }
 
+sub run_fork {
+    my ($code) = @_;
+    return run_fork_with_timeout(undef, $code);
+}
+
 # NOTE: NFS syscall can't be interrupted, so alarm does
 # not work to provide timeouts.
 # from 'man nfs': "Only SIGKILL can interrupt a pending NFS operation"