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::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;