Revert "Added timeout to UDP Server start and stop to kill generated zombies processes"

This reverts commit 5d8510da24.
This commit is contained in:
fermin831 2015-11-27 10:36:01 +01:00
parent 719ece1ce8
commit f10619d34d
1 changed files with 7 additions and 41 deletions

View File

@ -1879,7 +1879,7 @@ sub udp_server ($$) {
if (($udp_auth_address eq "0.0.0.0") || $address_found){
if ($newmsg =~ /REFRESH AGENT/){
# Send signal to restart agent
log_message ('udp server', 'Received refresh signal from '.$hishost);
log_message ('udp server', 'Received signal from '.$hishost);
kill 'SIGINT' , $parent_pid;
}
elsif ($newmsg =~ /START PROCESS (.*)/){
@ -1887,27 +1887,10 @@ sub udp_server ($$) {
$process_name =~ s/^\s*//g;
$process_name =~ s/\s*$//g;
if (defined($Conf{"process_${process_name}_start"})) {
# Configure a timeout to kill process if becomes zombie
eval {
local $SIG{ALRM} = sub{die;};
# Fixed timeout configured to 10
alarm(10);
log_message ('udp server', "Process $process_name started from $hishost");
if (fork() == 0) {
`$Conf{"process_${process_name}_start"} 2>$DevNull`;
alarm (0);
};
# If exceeded timeout, kill the process
if ($@) {
my $command_process = $Conf{"process_${process_name}_start"};
my $pid = `ps aux | grep "$command_process" | grep -v grep | awk '{print \$2}'`;
chomp ($pid);
# Some process can be generated with exceeded timeout. Kill every processes
my @processes = split (/\n/, $pid);
foreach my $single_process (@processes) {
`kill $single_process 2>$DevNull`;
log_message ('udp_server', "killed $single_process due to $process_name timeout exceeding");
}
} else {
log_message ('udp server', "Process $process_name started from $hishost");
exit 0;
}
} else {
log_message ('udp server', "Attempt to start unknown process $process_name from $hishost");
@ -1918,27 +1901,10 @@ sub udp_server ($$) {
$process_name =~ s/^\s*//g;
$process_name =~ s/\s*$//g;
if (defined($Conf{"process_${process_name}_stop"})) {
# Configure a timeout to kill process if becomes zombie
eval {
local $SIG{ALRM} = sub{die;};
# Fixed timeout configured to 10
alarm(10);
log_message ('udp server', "Process $process_name stopped from $hishost");
if (fork() == 0) {
`$Conf{"process_${process_name}_stop"} 2>$DevNull`;
alarm (0);
};
# If exceeded timeout, kill the process
if ($@) {
my $command_process = $Conf{"process_${process_name}_stop"};
my $pid = `ps aux | grep "$command_process" | grep -v grep | awk '{print \$2}'`;
chomp ($pid);
# Some process can be generated with exceeded timeout. Kill every processes
my @processes = split (/\n/, $pid);
foreach my $single_process (@processes) {
`kill $single_process 2>$DevNull`;
log_message ('udp_server', "killed $single_process due to $process_name timeout exceeding");
}
} else {
log_message ('udp server', "Process $process_name stopped from $hishost");
exit 0;
}
} else {
log_message ('udp server', "Attempt to stop unknown process $process_name from $hishost");