From 72800f281aab925dcdd606d41bf1644152a4e76a Mon Sep 17 00:00:00 2001
From: Ramon Novoa <rnovoa@artica.es>
Date: Mon, 19 Dec 2011 15:40:22 +0000
Subject: [PATCH] 2011-12-19  Ramon Novoa  <rnovoa@artica.es>

	* pandora_agent: Wait for broker childs instead of ignoring
	  SIGCHLD.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5282 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_agents/unix/ChangeLog     |  5 +++++
 pandora_agents/unix/pandora_agent | 10 ++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/pandora_agents/unix/ChangeLog b/pandora_agents/unix/ChangeLog
index 486547f1dc..c810e6632e 100644
--- a/pandora_agents/unix/ChangeLog
+++ b/pandora_agents/unix/ChangeLog
@@ -1,3 +1,8 @@
+2011-12-19  Ramon Novoa  <rnovoa@artica.es>
+
+	* pandora_agent: Wait for broker childs instead of ignoring
+	  SIGCHLD.
+
 2011-12-19  Ramon Novoa  <rnovoa@artica.es>
 
 	* pandora_agent: Ignore SIGCHLD.
diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent
index 16c9914cb9..5e15d0b1a7 100755
--- a/pandora_agents/unix/pandora_agent
+++ b/pandora_agents/unix/pandora_agent
@@ -114,7 +114,7 @@ my $ConfDir = '';
 my $ConfFile = 'pandora_agent.conf';
 
 # Broker agent configuration files
-my @BrokerConfFiles;
+my @BrokerPid;
 
 # Configuration tokens
 my %Conf = (
@@ -1589,9 +1589,6 @@ sub kill_signal_handler (){
 #Handler TERM signal.
 $SIG{'TERM'} = \&kill_signal_handler;
 
-# Ignore SIGCHLD
-$SIG{'CHLD'} = 'IGNORE';
-
 # Check command line arguments
 print_usage unless ($#ARGV == 0);
 $ConfDir = fix_directory ($ARGV[0]);
@@ -1719,6 +1716,8 @@ while (1) {
 					
 			# Execute
 			last;
+		} else {
+			push (@BrokerPid, $main_agent);
 		}
 	}
 
@@ -1851,6 +1850,9 @@ while (1) {
 
 	# Sleep if main agent
 	if ($main_agent != 0) {
+		foreach my $broker_pid (@BrokerPid) {
+			waitpid ($broker_pid, 0);
+		}
 		sleep ($Conf{'interval'});
 	}
 	# Finish if broker agent