Fixed that udp_server process is not terminated with parent pandora_agent

process termination.

(cherry picked from commit 897a38e316)
This commit is contained in:
Junichi Satoh 2015-12-21 15:41:25 +09:00
parent c20217abfb
commit 029c1c11d9
1 changed files with 13 additions and 2 deletions

View File

@ -213,6 +213,9 @@ my %Macros;
# PID of tentacle proxy, used in proxy mode
my $tentacle_pid = undef;
# PID of udp_server
my $udp_server_pid = undef;
################################################################################
# Print usage information and exit.
################################################################################
@ -1972,6 +1975,13 @@ sub kill_signal_handler (){
print "kill -9 $tentacle_pid\n";
`kill -9 $tentacle_pid`;
}
# Kill udp_server if it was forked.
if (defined ($udp_server_pid) && $udp_server_pid) {
kill 'TERM', $udp_server_pid;
log_message ('udp server', 'terminated.');
}
exit (0);
}
@ -2177,9 +2187,10 @@ $ENV{'PATH'} .= ":$ConfDir/plugins";
# Start UDP server if configured
if ($Conf{'udp_server'} == 1){
my $pid = fork();
$udp_server_pid = fork();
if ($pid == 0){
if ($udp_server_pid == 0){
$0 = 'udp_server (pandora_agent)';
udp_server ($Conf{'udp_server_port'}, $Conf{'udp_server_auth_address'});
exit;
}