diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-16 15:09:31 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-16 15:09:31 +0000 |
commit | be5f9e46eb176b948cf8e14d2be717e1027a1d93 (patch) | |
tree | 58dd6ed692243aaa8c1c4c970c25746342075404 /gcc/lock-and-run.sh | |
parent | f4b2c95ec5da39ce94e8827c9b3a106b95b06da9 (diff) | |
download | gcc-be5f9e46eb176b948cf8e14d2be717e1027a1d93.tar.gz |
* Makefile.in (LLINKER): New variable.
(mostlyclean): Remove link mutex.
* configure.ac: Handle --enable-link-mutex.
* lock-and-run.sh: New script.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198977 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lock-and-run.sh')
-rw-r--r-- | gcc/lock-and-run.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/lock-and-run.sh b/gcc/lock-and-run.sh new file mode 100644 index 00000000000..abefa068a55 --- /dev/null +++ b/gcc/lock-and-run.sh @@ -0,0 +1,29 @@ +#! /bin/sh +# Shell-based mutex using mkdir. + +lockdir=$1 prog=$2; shift 2 || exit 1 +count=0 +# Remember when we started trying to acquire the lock. +touch lock-stamp.$$ +trap 'rm -r "$lockdir" lock-stamp.$$' 0 +until mkdir "$lockdir" 2>/dev/null; do + # Say something periodically so the user knows what's up. + if [ `expr $count % 30` = 0 ]; then + # Reset if the lock has been renewed. + if [ -n "`find \"$lockdir\" -newer lock-stamp.$$`" ]; then + touch lock-stamp.$$ + count=1 + # Steal the lock after 5 minutes. + elif [ $count = 300 ]; then + echo removing stale $lockdir >&2 + rm -r "$lockdir" + else + echo waiting to acquire $lockdir >&2 + fi + fi + sleep 1 + count=`expr $count + 1` +done +echo $prog "$@" +$prog "$@" +# The trap runs on exit. |