[pve-devel] [PATCH common] don't double-exit
Dietmar Maurer
dietmar at proxmox.com
Wed Aug 22 18:12:22 CEST 2018
Is there a reason to change that (well tested) code?
> On August 22, 2018 at 4:04 PM Wolfgang Bumiller <w.bumiller at proxmox.com>
> wrote:
>
>
> if _exit() doesn't work, why would kill() be more
> reliable...
>
> Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
> ---
> src/PVE/RESTEnvironment.pm | 7 +++----
> src/PVE/Tools.pm | 1 -
> 2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm
> index 338a534..f9b3732 100644
> --- a/src/PVE/RESTEnvironment.pm
> +++ b/src/PVE/RESTEnvironment.pm
> @@ -561,7 +561,6 @@ sub fork_worker {
> POSIX::write($psync[1], $msg, length ($msg));
> POSIX::close($psync[1]);
> POSIX::_exit(1);
> - kill(-9, $$);
> }
>
> # sync with parent (signal that we are ready)
> @@ -580,21 +579,21 @@ sub fork_worker {
> &$function($upid);
> };
> my $err = $@;
> + my $ret = 0;
> if ($err) {
> + $ret = -1;
> chomp $err;
> $err =~ s/\n/ /mg;
> syslog('err', $err);
> my $msg = "TASK ERROR: $err\n";
> POSIX::write($resfh, $msg, length($msg));
> POSIX::close($resfh) if $sync;
> - POSIX::_exit(-1);
> } else {
> my $msg = "TASK OK\n";
> POSIX::write($resfh, $msg, length($msg));
> POSIX::close($resfh) if $sync;
> - POSIX::_exit(0);
> }
> - kill(-9, $$);
> + POSIX::_exit($ret);
> }
>
> # parent
> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index 06da78b..d9115c3 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -444,7 +444,6 @@ sub run_command {
> if ($orig_pid != $$) {
> warn "ERROR: $err";
> POSIX::_exit (1);
> - kill ('KILL', $$);
> }
>
> die $err if $err;
> --
> 2.11.0
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list