]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Tools.pm
run fork with timeout: only special case timeout error in list context
[pve-common.git] / src / PVE / Tools.pm
index 724fb696b2c7c78a7dd4168ca9914a4bf2573683..2cfe93f7f0f4cbe909a3c2df54aac3ec825d0e4a 100644 (file)
@@ -1017,10 +1017,16 @@ sub run_fork_with_timeout {
        $res = $child_res->{result};
        $error = $child_res->{error};
     };
+
     my $got_timeout = 0;
+    my $wantarray = wantarray; # so it can be queried inside eval
     eval {
        if (defined($timeout)) {
-           (undef, $got_timeout) = run_with_timeout($timeout, $readvalues);
+           if ($wantarray) {
+               (undef, $got_timeout) = run_with_timeout($timeout, $readvalues);
+           } else {
+               run_with_timeout($timeout, $readvalues);
+           }
        } else {
            $readvalues->();
        }