Fixed zombie processes are created when xml transfer is timed out.

(cherry picked from commit 41e6d71159)
This commit is contained in:
Junichi Satoh 2015-12-14 10:03:57 +09:00
parent 27624a4d70
commit 861a749654
1 changed files with 81 additions and 57 deletions

View File

@ -824,6 +824,11 @@ sub send_file {
my ($file, $secondary) = @_;
my $output;
my $pid = fork();
return 1 unless defined $pid;
if ($pid == 0) {
# execute the transfer program by child process.
eval {
local $SIG{'ALRM'} = sub {die};
alarm ($Conf{'transfer_timeout'});
@ -850,14 +855,21 @@ sub send_file {
};
if ($@) {
$output = "File transfer command is not responding.";
log_message ('error', "Error sending file '$file': File transfer command is not responding.");
exit 1;
}
# Get the errorlevel
my $rc = $? >> 8;
if ($rc != 0 || $@) {
if ($rc != 0) {
log_message ('error', "Error sending file '$file': $output");
}
exit $rc;
}
# Wait the child process termination and get the errorlevel
waitpid ($pid, 0);
my $rc = $? >> 8;
return $rc unless (defined ($secondary));
@ -916,6 +928,11 @@ sub recv_file ($) {
my $file = shift;
my $output;
my $pid = fork();
return 1 unless defined $pid;
if ($pid == 0) {
# execute the transfer program by child process.
eval {
local $SIG{'ALRM'} = sub {die};
alarm ($Conf{'transfer_timeout'});
@ -942,14 +959,21 @@ sub recv_file ($) {
};
if ($@) {
$output = "File transfer command is not responding.";
log_message ('error', "Error retrieving file: File transfer command is not responding.");
exit 1;
}
# Get the errorlevel
my $rc = $? >> 8;
if ($rc != 0 || $@) {
if ($rc != 0) {
log_message ('error', "Error retrieving file: $output");
}
exit $rc;
}
# Wait the child process termination and get the errorlevel
waitpid ($pid, 0);
my $rc = $? >> 8;
return $rc;
}