From 11aff4cf63f9af5d2421e98976e5abfa571fbc02 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Tue, 2 Aug 2016 17:54:37 +0200 Subject: [PATCH] + add autokill system for childs --- .../vmware/src/centreon/vmware/cmdbase.pm | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/connectors/vmware/src/centreon/vmware/cmdbase.pm b/connectors/vmware/src/centreon/vmware/cmdbase.pm index 9d33ca6dd..5c72067f4 100644 --- a/connectors/vmware/src/centreon/vmware/cmdbase.pm +++ b/connectors/vmware/src/centreon/vmware/cmdbase.pm @@ -21,6 +21,8 @@ package centreon::vmware::cmdbase; use strict; use warnings; +my %handlers = (ALRM => {}); + sub new { my ($class, %options) = @_; my $self = {}; @@ -36,10 +38,32 @@ sub getCommandName { return $self->{commandName}; } +sub set_signal_handlers { + my $self = shift; + + $SIG{ALRM} = \&class_handle_ALRM; + $handlers{ALRM}->{$self} = sub { $self->handle_ALRM() }; +} + +sub class_handle_ALRM { + foreach (keys %{$handlers{ALRM}}) { + &{$handlers{ALRM}->{$_}}(); + } +} + +sub handle_ALRM { + my $self = shift; + + $self->{logger}->writeLogError("Child process autokill!!"); + exit(0); +} + sub set_connector { my ($self, %options) = @_; $self->{connector} = $options{connector}; + $self->set_signal_handlers(); + alarm(300); } 1;