fork_worker: guard more setup code with eval

As it might die with an error which should end up in the
_exit() code path rather than bailing out into the upper
scope.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2017-12-27 11:06:07 +01:00
parent 4d9f4d62e4
commit 2311859b0d

View File

@ -561,15 +561,17 @@ sub fork_worker {
POSIX::write($psync[1], $upid, length ($upid)); POSIX::write($psync[1], $upid, length ($upid));
POSIX::close($psync[1]) if !$sync; # don't need output pipe if async POSIX::close($psync[1]) if !$sync; # don't need output pipe if async
my $readbuf = ''; eval {
# sync with parent (wait until parent is ready) my $readbuf = '';
POSIX::read($csync[0], $readbuf, 4096); # sync with parent (wait until parent is ready)
die "parent setup error\n" if $readbuf ne 'OK'; POSIX::read($csync[0], $readbuf, 4096);
die "parent setup error\n" if $readbuf ne 'OK';
if ($self->{type} eq 'ha') { if ($self->{type} eq 'ha') {
print "task started by HA resource agent\n"; print "task started by HA resource agent\n";
} }
eval { &$function($upid); }; &$function($upid);
};
my $err = $@; my $err = $@;
if ($err) { if ($err) {
chomp $err; chomp $err;