about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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