about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <charadon@charadon-gmpc.hsd1.ga.comcast.net>2022-07-14 00:57:33 -0400
committerCharadon <charadon@charadon-gmpc.hsd1.ga.comcast.net>2022-07-14 00:57:33 -0400
commit905c436f2b1e0c74a2d858bf09b320f54292b251 (patch)
tree53bd64cf906d73d89ed86377fd3754b1a257c525
parentf1d82781ed9ff96fd936921e96792d3826be8931 (diff)
downloaddscip-905c436f2b1e0c74a2d858bf09b320f54292b251.tar.gz
Added lock functionality
-rwxr-xr-xdscip13
1 files changed, 13 insertions, 0 deletions
diff --git a/dscip b/dscip
index 045cd65..c35ae3b 100755
--- a/dscip
+++ b/dscip
@@ -44,6 +44,18 @@ DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even #
 
 ################################################################################
 
+# Check if script is currently running, and if not, reset LOCK #
+if [ -f $WORKING_DIRECTORY/LOCK ]; then
+	LOCKED_PID=$(cat $WORKING_DIRECTORY/LOCK)
+	if ps -p $LOCKED_PID; then
+		exit 0
+	else
+		rm $WORKING_DIRECTORY/LOCK
+	fi
+fi
+
+echo "$$" > $WORKING_DIRECTORY/LOCK
+
 if [ "$DSCIP_DAEMON" = "true" ]; then
 	if [ "$DSCIP_DAEMON_FORK" = "true" ] && [ ! "$FORKED" = "true" ]; then
 		FORKED=true nohup "$0" "$@" > /dev/null 2>&1
@@ -98,6 +110,7 @@ run () {
 	else
 		build
 	fi
+	rm $WORKING_DIRECTORY/LOCK # Remove lock #
 }
 
 run