]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/RESTEnvironment.pm
fork_worker: guard more setup code with eval
[pve-common.git] / src / PVE / RESTEnvironment.pm
index 91de8750595a75042fe775f9168b5606cf88dbbd..ebf8a2e7aaaadc8e88b50929b8f15e6e00e98dbd 100644 (file)
@@ -525,7 +525,7 @@ sub fork_worker {
                    if !open(STDIN, "</dev/null");
 
                $outfh = PVE::Tools::upid_open($upid);
-               $resfh = $outfh;
+               $resfh = fileno($outfh);
            }
 
 
@@ -561,15 +561,17 @@ sub fork_worker {
        POSIX::write($psync[1], $upid, length ($upid));
        POSIX::close($psync[1]) if !$sync; # don't need output pipe if async
 
-       my $readbuf = '';
-       # sync with parent (wait until parent is ready)
-       POSIX::read($csync[0], $readbuf, 4096);
-       die "parent setup error\n" if $readbuf ne 'OK';
+       eval {
+           my $readbuf = '';
+           # sync with parent (wait until parent is ready)
+           POSIX::read($csync[0], $readbuf, 4096);
+           die "parent setup error\n" if $readbuf ne 'OK';
 
-       if ($self->{type} eq 'ha') {
-           print "task started by HA resource agent\n";
-       }
-       eval { &$function($upid); };
+           if ($self->{type} eq 'ha') {
+               print "task started by HA resource agent\n";
+           }
+           &$function($upid);
+       };
        my $err = $@;
        if ($err) {
            chomp $err;