A scratch directory per run, after two of them shared one

This commit is contained in:
Joseph Ferano 2026-09-13 23:05:12 +07:00
parent 6c15eef5e5
commit 368866c63d

View File

@ -54,8 +54,15 @@ test -x "$flan" || { echo "build failed" >&2; exit 1; }
# Not mktemp under /tmp by default: this writes a few hundred executables of
# a megabyte or two, and a full /tmp on this machine has already frozen one
# session. The guard is cheap and a wedged run is not.
out=${COST_OUT:-${TMPDIR:-/tmp}/flan-cost.$$}
mkdir -p "$out" || exit 1
# A directory of this run's own, made with a plain mkdir so that a second
# copy of this script cannot land in the first one's: two runs sharing a
# scratch directory overwrite each other's `l` and `x` between the build and
# the timing, and the result is a row of numbers that belong to two different
# programs. That happened once here and the numbers looked entirely ordinary.
work=${COST_OUT:-${TMPDIR:-/tmp}/flan-cost}
mkdir -p "$work" || exit 1
out=$work/run.$$
mkdir "$out" || exit 1
trap 'rm -rf "$out"' EXIT
free=$(df -Pk "$out" | awk 'NR==2 {print $4}')
[ "$free" -gt 2000000 ] || { echo "less than 2GB free at $out" >&2; exit 1; }