automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FYI: fix race condition in elisp's recover rule


From: Akim Demaille
Subject: Re: FYI: fix race condition in elisp's recover rule
Date: Tue, 29 Mar 2005 23:24:22 +0200


Le 29 mars 05, à 20:46, Alexandre Duret-Lutz a écrit :

+data.c data.h data.w data.x: data.stamp
+## Recover from the removal of $@@
+        @@if test -f $@@; then :; else \
+          trap 'rm -rf data.lock data.stamp 1 2 13 15; \
+## mkdir is a portable test-and-set
+          if mkdir data.lock 2>/dev/null; then \
+## This code is being executed by the first process.
+            rm -f data.stamp; \
+            $(MAKE) $(AM_MAKEFLAGS) data.stamp; \
+          else \
+## This code is being executed by the follower processes.
+## Wait until the first process is done.
+            while test -d data.lock; do sleep 1; done; \
+## Succeed if and only if the first process succeeded.
+            test -f data.stamp; exit $$?; \
+        fi

How about shipping a program that does that?  It just needs
$@ and $<.  That would save several of us from having to update
our code that does just that.

In fact, I would love to see Automake do all this itself when
there are several outputs listed :)


BTW, maybe you do not want to clutter the documentation
of Automake with non portable Make matters, but it is
worth noting that GNU Make does the right things for
rules with several % on the lhs.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]