]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/lock-and-run.sh
2 # Shell-based mutex using mkdir.
4 lockdir
=$1 prog
=$2; shift 2 ||
exit 1
6 # Remember when we started trying to acquire the lock.
8 trap 'rm -r "$lockdir" lock-stamp.$$' 0
9 until mkdir
"$lockdir" 2>/dev
/null
; do
10 # Say something periodically so the user knows what's up.
11 if [ `expr $count % 30` = 0 ]; then
12 # Reset if the lock has been renewed.
13 if [ -n "`find \"$lockdir\" -newer lock-stamp.$$`" ]; then
16 # Steal the lock after 5 minutes.
17 elif [ $count = 300 ]; then
18 echo removing stale
$lockdir >&2
21 echo waiting to acquire
$lockdir >&2
25 count
=`expr $count + 1`
29 # The trap runs on exit.