From 187aea7087ef399a832c3c265e43e67328404dc8 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 21 Jan 2014 12:04:05 +0100 Subject: [PATCH] detect forked connections Else more than one process can kill our worker! --- PVE/RADOS.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PVE/RADOS.pm b/PVE/RADOS.pm index 76c9d7b..c8044b7 100644 --- a/PVE/RADOS.pm +++ b/PVE/RADOS.pm @@ -83,6 +83,9 @@ my $kill_worker = sub { close($self->{child}) if defined($self->{child}); + # only kill if we created the process + return if $self->{pid} != $$; + kill(9, $self->{cpid}); waitpid($self->{cpid}, 0); }; @@ -92,6 +95,8 @@ my $sendcmd = sub { $expect_tag = '>' if !$expect_tag; + die "detected forked connection" if $self->{pid} != $$; + my ($restag, $raw); my $code = sub { &$writedata($self->{child}, $cmd, $data) if $expect_tag ne 'S'; @@ -129,6 +134,7 @@ sub new { my $timeout = delete $params{timeout} || $rados_default_timeout; $self->{timeout} = $timeout; + $self->{pid} = $$; if ($cpid) { # parent close $parent; -- 2.39.2