tools/hotplug/Linux: forced to release lock if holder process is gone
authorKouya Shimura <kouya@jp.fujitsu.com>
Tue, 14 Dec 2010 17:15:48 +0000 (17:15 +0000)
committerKouya Shimura <kouya@jp.fujitsu.com>
Tue, 14 Dec 2010 17:15:48 +0000 (17:15 +0000)
When a script using locking.sh is stopped by ctrl-C, the lock file remains.
We have to wait 100 seconds for releasing the lock at the next time.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/hotplug/Linux/locking.sh

index 7dbd6bef810581e9cbcb0e1b7e9d6fc3f81d10dc..8748d95454b6b053e711deee76c318f1ac3de2cd 100644 (file)
@@ -61,6 +61,12 @@ _claim_lock()
     then
       owner="$new_owner"
       retries=0
+    else
+      local pid=$(echo $owner | cut -d : -f 1)
+      if [ ! -f "/proc/$pid/status" ]
+      then
+        _release_lock $lockdir
+      fi
     fi
 
     if [ $retries -gt $LOCK_SPINNING_RETRIES ]