From: Wolfgang Bumiller Date: Wed, 27 Dec 2017 10:06:07 +0000 (+0100) Subject: fork_worker: guard more setup code with eval X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=2311859b0da26e1806f5015783bfebb5aca16300 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 Reviewed-by: Thomas Lamprecht --- diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm index 871f12b..ebf8a2e 100644 --- a/src/PVE/RESTEnvironment.pm +++ b/src/PVE/RESTEnvironment.pm @@ -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;