]> git.proxmox.com Git - pve-common.git/commitdiff
tools: more general run_fork_with_timeout + run_fork
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 10 Oct 2017 08:08:12 +0000 (10:08 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 13 Oct 2017 11:21:44 +0000 (13:21 +0200)
src/PVE/Tools.pm

index bd99914c58e780d4eba4204eb500e739ae000b15..2525e55ceb95ed1b9fccf41b9e8defa03db81dd9 100644 (file)
@@ -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"