Fix a problem where the test cases were sometimes failing

Estimated hours taken: 0.5

Fix a problem where the test cases were sometimes failing
if old /tmp/mmake* directories were left 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.
This commit is contained in:
Fergus Henderson
1999-10-11 05:47:12 +00:00
parent c4b86a47d5
commit 98e67d2201
2 changed files with 31 additions and 19 deletions

View File

@@ -591,15 +591,21 @@ case $demangle in
# create the pipe, making sure we remove it if interrupted # create the pipe, making sure we remove it if interrupted
old_umask=`umask` old_umask=`umask`
umask 022 umask 022
ML_TMPDIR=$TMPDIR/ml$$ try=0
PIPE=$ML_TMPDIR/pipe until
trap 'rmdir $ML_TMPDIR >/dev/null 2>&1; exit 1' 1 2 3 13 15 ML_TMPDIR=$TMPDIR/ml$$
if mkdir $ML_TMPDIR ; then PIPE=$ML_TMPDIR/pipe
true trap 'rmdir $ML_TMPDIR >/dev/null 2>&1; exit 1' 1 2 3 13 15
else mkdir $ML_TMPDIR
echo "Unable to create temporary pipe" 1>&2 do
exit 1 try="`expr $try + 1`"
fi # 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 trap 'rm -rf $ML_TMPDIR; exit 1' 1 2 3 13 15
umask $old_umask umask $old_umask
$MKFIFO $PIPE $MKFIFO $PIPE

View File

@@ -182,16 +182,22 @@ else
case "$MKTEMP" in case "$MKTEMP" in
"") old_umask=`umask` "") old_umask=`umask`
umask 022 umask 022
mmake_tmpdir=$TMPDIR/mmake$$ try=0
tmp=$mmake_tmpdir/mmake until
trap 'rmdir $mmake_tmpdir >/dev/null 2>&1; exit 1' \ mmake_tmpdir=$TMPDIR/mmake$$-$try
1 2 3 13 15 tmp=$mmake_tmpdir/mmake
if mkdir $mmake_tmpdir ; then trap 'rmdir $mmake_tmpdir >/dev/null 2>&1; exit 1' \
true 1 2 3 13 15
else mkdir $mmake_tmpdir
echo "Unable to create temporary makefile" 1>&2 do
exit 1 try=`expr $try + 1`
fi # 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' \ trap 'status=$?; rm -rf $mmake_tmpdir; exit $status' \
0 1 2 3 13 15 0 1 2 3 13 15
umask $old_umask umask $old_umask