On May  9, 2013, Jason Merrill <ja...@redhat.com> wrote:

> On 05/01/2013 07:40 PM, Mike Stump wrote:
>> $ bash -c "trap 'echo remove lock' 0; true"; echo $?

> Thanks for the suggestion.  Here's a revised patch:

I like the idea of the patch, for I feel your pain too ;-)

However, rather than implementing the locking in Makefiles, I'm thinking
it might be wiser to do so in a script that takes the lock name and the
command to run while holding the lock.

ifeq (@DO_LINK_MUTEX@,true)
LLINKER = $(SHELL) $(srcdir)/lock-and-run linkfe.lck $(LINKER)
else
LLINKER = $(LINKER)
endif

lock-and-run:
#! /bin/sh
lockdir=$1 prog=$2; shift 2 || exit 1
status=1
trap 'rmdir "$lockdir"; exit $status' 0 1 2 15
until mkdir "$lockdir"; do sleep 1; done
$prog "$@"
status=$?
rmdir "$lockdir"
exit $status

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Reply via email to