# General locking with mkdir is simple:
mkdir LOCK 2>/dev/null || exit 0
echo running locked
rmdir LOCK

# Locking with ln (ignoring System V) is somewhat more complicated:
echo $$ >$$
if ln $$ LOCK 2>/dev/null; then
  echo running locked
  rm $$ LOCK
else
  rm $$
fi
