Skip to content
Snippets Groups Projects
Commit 0061751e authored by Carmelo Pellegrino's avatar Carmelo Pellegrino
Browse files

clean-up implemented through trap on exit

parent c0cf07e8
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,16 @@ function test_lock() {
fi
}
function on_exit() {
if [ "${LOCK_OWNER}" == "True" ]; then
rm_lock
fi
for pid in ${PROCS}; do
kill -9 ${pid}
done
}
function createList() {
local LIST
local file
......@@ -73,6 +83,9 @@ function get_run_number() {
test_lock || { zenity --error --text="There is another instance running of this program."; exit 1;}
put_lock
LOCK_OWNER="True"
trap on_exit EXIT
while [ 1 ]; do
......@@ -88,7 +101,6 @@ while [ 1 ]; do
if [ -z "${rs_file}" ]; then
zenity --error --text="No Run Setup file selectet, aborting"
rm_lock
exit -1
fi
......@@ -125,6 +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
# Copy selected run setup file, changing the run number
......@@ -134,6 +147,7 @@ run_start_time=`nowUTC`
# Launch the DM
dm_driver ${run_duration} | mono DetectorControl.exe --control --reset &
PROCS=(${PROCS} $!)
# Launch the DAQ
log "Launching the DAQ with the following command line: daq.sh ${run_number} ${run_start_time} ${run_duration}"
......@@ -149,6 +163,4 @@ sleep ${run_duration}
zenity --info --text="Run ${run_number} finished!"
rm_lock
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment