[m-dev.] diff: handle mkdir failure in scripts/{ml,mmake}
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Oct 11 15:43:04 AEST 1999
Estimated hours taken: 0.5
Fix a problem where the test cases were sometimes failing
if there were old `/tmp/mmake*' directories lying around.
scripts/ml.in:
scripts/mmake.in:
When creating the temporary directory, if mkdir fails (e.g.
because that directory already exists), then try again with a
different directory name. Only report an error if it fails 20
times in a row.
Workspace: /home/mercury0/fjh/mercury
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.67
diff -u -r1.67 ml.in
--- ml.in 1999/10/01 19:12:06 1.67
+++ ml.in 1999/10/11 05:32:46
@@ -591,15 +591,21 @@
# create the pipe, making sure we remove it if interrupted
old_umask=`umask`
umask 022
- ML_TMPDIR=$TMPDIR/ml$$
- PIPE=$ML_TMPDIR/pipe
- trap 'rmdir $ML_TMPDIR >/dev/null 2>&1; exit 1' 1 2 3 13 15
- if mkdir $ML_TMPDIR ; then
- true
- else
- echo "Unable to create temporary pipe" 1>&2
- exit 1
- fi
+ try=0
+ until
+ ML_TMPDIR=$TMPDIR/ml$$
+ PIPE=$ML_TMPDIR/pipe
+ trap 'rmdir $ML_TMPDIR >/dev/null 2>&1; exit 1' 1 2 3 13 15
+ mkdir $ML_TMPDIR
+ do
+ try="`expr $try + 1`"
+ # give up after 20 tries
+ case "$try" in 20)
+ echo "ml: unable to create temporary directory" \
+ "for pipe" 1>&2
+ exit 1
+ esac
+ done
trap 'rm -rf $ML_TMPDIR; exit 1' 1 2 3 13 15
umask $old_umask
$MKFIFO $PIPE
Index: scripts/mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.29
diff -u -r1.29 mmake.in
--- mmake.in 1999/09/10 08:50:04 1.29
+++ mmake.in 1999/10/11 05:37:42
@@ -182,16 +182,22 @@
case "$MKTEMP" in
"") old_umask=`umask`
umask 022
- mmake_tmpdir=$TMPDIR/mmake$$
- tmp=$mmake_tmpdir/mmake
- trap 'rmdir $mmake_tmpdir >/dev/null 2>&1; exit 1' \
- 1 2 3 13 15
- if mkdir $mmake_tmpdir ; then
- true
- else
- echo "Unable to create temporary makefile" 1>&2
- exit 1
- fi
+ try=0
+ until
+ mmake_tmpdir=$TMPDIR/mmake$$-$try
+ tmp=$mmake_tmpdir/mmake
+ trap 'rmdir $mmake_tmpdir >/dev/null 2>&1; exit 1' \
+ 1 2 3 13 15
+ mkdir $mmake_tmpdir
+ do
+ try=`expr $try + 1`
+ # give up after 20 tries
+ case $try in 20)
+ echo "mmake: unable to create directory" \
+ "for temporary makefile" 1>&2
+ exit 1
+ esac
+ done
trap 'status=$?; rm -rf $mmake_tmpdir; exit $status' \
0 1 2 3 13 15
umask $old_umask
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list