Fixed zombie processes are created when xml transfer is timed out.
(cherry picked from commit 41e6d71159
)
This commit is contained in:
parent
27624a4d70
commit
861a749654
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue