mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
Fixed zombie processes are created when xml transfer is timed out.
This commit is contained in:
parent
9697c1fcf0
commit
41e6d71159
@ -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…
x
Reference in New Issue
Block a user