From: Fiona Ebner Date: Wed, 30 Aug 2023 13:07:52 +0000 (+0200) Subject: run fork with timeout: only special case timeout error in list context X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=41ed4396350713aa592aeb615a84363e2ce9298e run fork with timeout: only special case timeout error in list context run_with_timeout() will treat a timeout error differently when called in list context and run_fork_with_timeout() should do the same. Ensure this by calling run_with_timeout() in list context if and only if run_fork_with_timeout() is called in list context too. Fixes: a6aa0ae ("run with timeout: return if timeout happened in list context") Signed-off-by: Fiona Ebner --- diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 724fb69..2cfe93f 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -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->(); }