From 628d4ccb6fc8b8490642fe19e7fe5347ddefe189 Mon Sep 17 00:00:00 2001
From: Carmelo Pellegrino <carmelo.pellegrino@gmail.com>
Date: Wed, 20 May 2015 11:48:07 +0200
Subject: [PATCH] correcting implementation of process cleanup

---
 patch-control.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/patch-control.sh b/patch-control.sh
index afa5594..5eea432 100644
--- a/patch-control.sh
+++ b/patch-control.sh
@@ -29,7 +29,7 @@ function on_exit() {
     rm_lock
   fi
 
-  for pid in ${PROCS}; do
+  for pid in ${PROCS[*]}; do
     kill -9 ${pid}
   done
 }
@@ -137,8 +137,7 @@ run_number=`get_run_number`
 
 daq_log_file=~/.km3_private/daq_${run_number}.log
 JGetMessage -H localhost -T MSG -d 3 >${daq_log_file} &
-PROCS=(${PROCS} $!)
-## impl: get the pid and add to the list of must_kill_at_the_exit
+PROCS=(${PROCS[*]} $!)
 
 # Copy selected run setup file, changing the run number
 cat ${rs_file} | sed -e 's/RUNNUMBER/${run_number}/' >dm.detectorfile
@@ -147,7 +146,7 @@ run_start_time=`nowUTC`
 
 # Launch the DM
 dm_driver ${run_duration} | mono DetectorControl.exe --control --reset &
-PROCS=(${PROCS} $!)
+PROCS=(${PROCS[*]} $!)
 
 # Launch the DAQ
 log "Launching the DAQ with the following command line: daq.sh ${run_number} ${run_start_time} ${run_duration}"
-- 
GitLab