[csw-devel] SF.net SVN: opencsw:[649] buildfarm/bin/opencsw-future-update

dmichelsen at users.sourceforge.net dmichelsen at users.sourceforge.net
Fri Feb 8 13:26:58 CET 2013


Revision: 649
          http://opencsw.svn.sourceforge.net/opencsw/?rev=649&view=rev
Author:   dmichelsen
Date:     2013-02-08 12:26:58 +0000 (Fri, 08 Feb 2013)
Log Message:
-----------
opencsw-future-update: Cleanup stale locks

Modified Paths:
--------------
    buildfarm/bin/opencsw-future-update

Modified: buildfarm/bin/opencsw-future-update
===================================================================
--- buildfarm/bin/opencsw-future-update	2013-01-31 15:19:23 UTC (rev 648)
+++ buildfarm/bin/opencsw-future-update	2013-02-08 12:26:58 UTC (rev 649)
@@ -9,14 +9,23 @@
 declare -r BASE_DIR=$(dirname $0)
 
 readonly lockpath=/var/tmp/catalog-generation.lock
+readonly pidfile=${lockpath}/pid
 
 if ! mkdir "${lockpath}"; then
-  echo "'${lockpath}' is locked, '$0' is exiting."
-  exit 1
+  if [ -f "${pidfile}" ]; then
+    if kill -0 `cat "${pidfile}"` 2>/dev/null; then
+      echo "${lockpath} is locked, '$0' is exiting."
+      exit 1
+    fi
+    echo "Removing stale lockfile ${pidfile}, continuing."
+    rm -f ${pidfile}
+  else
+    echo "'${lockpath}' is locked, but there is no pidfile, continuing."
+  fi
 fi
 
-trap "rm -f \"${lockpath}\"/pid; rmdir \"${lockpath}\"; exit 0" 1 2 3 5 6 15 ERR
-echo $$ > "${lockpath}/pid"
+trap "rm -f \"${pidfile}\"; rmdir \"${lockpath}\"; exit 0" 1 2 3 5 6 15 ERR
+echo $$ > "${pidfile}"
 
 ${BASE_DIR}/sync-mirror
 ${BASE_DIR}/sync-checkpkg
@@ -29,5 +38,5 @@
 
 echo "$0 completed successfully"
 
-rm -f "${lockpath}/pid"
+rm -f "${pidfile}"
 rmdir "${lockpath}"

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list