hbbs

[archived] bbs.hlirc.net
git clone https://hhvn.uk/hbbs
git clone git://hhvn.uk/hbbs
Log | Files | Refs | README | LICENSE

lock.sh (266B)


      1 #!/bin/sh
      2 
      3 lock(){
      4 	locklist=$(echo "$locklist"; echo "$1")
      5 	while [ -f $1.lock ]
      6 	do
      7 		sleep 0.5
      8 	done
      9 	touch $1.lock
     10 }
     11 
     12 unlock(){
     13 	locklist=$(echo "$locklist" | grep -v "^$1$")
     14 	rm $1.lock
     15 }
     16 
     17 unlock_all(){
     18 	for f in $locklist
     19 	do
     20 		rm $f.lock
     21 	done
     22 	locklist=""
     23 }