tech-userlevel archive

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

Change to genassym to use mktemp(1) to create tempdir



At my $DAYJOB, we encounter occasional build failures when genassym
can't create its temporary directory because that directory already
exists from a previous build. I have not yet been able to determine
why this happens, especially since the genassym script contains a
"trap" to remove the directory on exit/error.

The stale temp directories contain either a truncated or a zero-length
genassym.out file. I suspect the problem may be related to our Linux
build servers or the distributed make system we use, perhaps when a
build's job steps are forcefully migrated to another node when a
higher priority build is dispatched, such that the trap does not fire.

Since tracking down the root cause is secondary to avoiding spurious
build failures, I changed to genassym.sh to use mktemp(1) to create
its temporary directory instead of using "mkdir /tmp/genassym.$$".

While this failure seems unlikely, I offer the patch, as it does make
genassym slightly more reliable.

    --jtc

Index: genassym.sh
===================================================================
RCS file: /cvsroot/src/usr.bin/genassym/genassym.sh,v
retrieving revision 1.7
diff -u -r1.7 genassym.sh
--- genassym.sh 5 Jul 2011 05:19:02 -0000       1.7
+++ genassym.sh 6 Jan 2014 19:40:41 -0000
@@ -69,9 +69,9 @@
        esac
 done
 
-genassym_temp=/tmp/genassym.$$
+genassym_temp=`mktemp -d -q ${TMPDIR-/tmp}/genassym.XXXXXX`
 
-if ! mkdir $genassym_temp; then
+if ! test -d $genassym_temp; then
        echo "${progname}: unable to create temporary directory" >&2
        exit 1
 fi

-- 
J.T. Conklin


Home | Main Index | Thread Index | Old Index