Here another

key=$RANDOM

if [ ! -e /tmp/flag ]; then
   touch /tmp/flag 
fi

#Trying to release the lock
while [ mv /tmp/flag  /tmp/flag.$key ]; do
# here can be a sleep or not...
done

 # do locked stuff here
...

#Release the lock
mv mv /tmp/flag.$key /tmp/flag  

I not trying but you can use a environment variable also to obtain the lock 
implementing a mutex standard algoritm
--
This message posted from opensolaris.org

Reply via email to