From 41b3a8ed8b2480ca12baaa6c692a7fba3ebd53cf Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 4 Nov 2009 14:02:20 -0700 Subject: mktemp: don't leave file behind on write failure * src/mktemp.c (main): Remove just-created file if stdout had problems. * bootstrap.conf (gnulib_modules): Add remove. * tests/misc/close-stdout: Test it. * NEWS: Document it. --- tests/misc/close-stdout | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout index fec1addc8..852c3c822 100755 --- a/tests/misc/close-stdout +++ b/tests/misc/close-stdout @@ -50,12 +50,18 @@ if "$p/src/test" -w /dev/stdout >/dev/null && "$p/src/test" ! -w /dev/stdout >&-; then "$p/src/printf" 'foo' >&- 2>/dev/null && fail=1 cp --verbose a b >&- 2>/dev/null && fail=1 + rm -Rf tmpfile-?????? || fail=1 + mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1 + test -e tmpfile-?????? && fail=1 fi # Likewise for /dev/full, if /dev/full works. if test -w /dev/full && test -c /dev/full; then "$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1 cp --verbose a b >/dev/full 2>/dev/null && fail=1 + rm -Rf tmpdir-?????? || fail=1 + mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1 + test -e tmpdir-?????? && fail=1 fi Exit $fail -- cgit v1.2.3-70-g09d2