From a2d049afde002df646af4eed4b2c5ec22a251400 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 10 Oct 2017 10:08:12 +0200 Subject: [PATCH] tools: more general run_fork_with_timeout + run_fork --- src/PVE/Tools.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index bd99914..2525e55 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -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" -- 2.39.2