More check of the lock file in autotest_cgal: the lock file will now

contain the PID of the running autotest_cgal process. That PID can be
checked and displayed if the lock cannot be acquired.
This commit is contained in:
Laurent Rineau 2010-06-17 09:33:00 +00:00
parent 0603ea69f7
commit 680ae36873
1 changed files with 16 additions and 3 deletions

View File

@ -863,11 +863,24 @@ else
fi
# Acquire lock
lockfile -r 5 "$LOCK_FILE";
lockfile -r 1 "$LOCK_FILE";
if [ ${?} != 0 ]; then
echo "COULD NOT AQUIRE LOCK!";
exit 1;
PID=`cat "$LOCK_FILE"`
if kill -0 "$PID"; then
log "COULD NOT AQUIRE LOCK! LOCKING PROCESS PID=$PID";
exit 1;
else
# The locking process has died without erasing the lock file
rm -f "$LOCK_FILE"
lockfile -r 1 "$LOCK_FILE";
if [ ${?} != 0 ]; then
log "COULD NOT AQUIRE LOCK!";
exit 1
fi
fi
fi
# Put the PID of current process in the lock file
echo $$ >> "$LOCK_FILE"
# that line makes the script remove the lock file in case of unwanted exit
trap "rm -f $LOCK_FILE" EXIT HUP INT TERM