From 726d3baa33a57850143d48bb0158f3bddbbebac0 Mon Sep 17 00:00:00 2001
From: Carmelo Pellegrino <carmelo.pellegrino@gmail.com>
Date: Thu, 14 May 2015 18:47:50 +0200
Subject: [PATCH] lock and error message in case of already locked implemented

---
 rsselector.sh | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/rsselector.sh b/rsselector.sh
index c6ba09f..96aaf65 100644
--- a/rsselector.sh
+++ b/rsselector.sh
@@ -16,7 +16,11 @@ function rm_lock() {
 }
 
 function test_lock() {
-  return [ -e /tmp/auto_ss ]
+  if [ -e /tmp/auto_ss ]; then
+    return 1
+  else
+    return 0
+  fi
 }
 
 function createList() {
@@ -64,6 +68,11 @@ function get_run_number() {
   echo ${run_number}
 }
 
+
+test_lock || { zenity --error --text="There is another instance running of this program."; exit 1;}
+
+put_lock
+
 while [ 1 ]; do
 
   # Ask for the run setup
@@ -138,4 +147,6 @@ sleep ${run_duration}
 
 zenity --info --text="Run ${run_number} finished!"
 
+rm_lock
+
 exit 0
-- 
GitLab