summaryrefslogtreecommitdiff
path: root/tests/misc/close-stdout
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-11-05 12:19:45 -0700
committerEric Blake <ebb9@byu.net>2009-11-07 10:10:25 -0700
commitc768e2231b89901a2e29c3bf96c027b64f8646d9 (patch)
treeef0381745bb5f50fd882100375921cccfd3ddd87 /tests/misc/close-stdout
parent9a8d8f46a541d333f98dca26d053d1f5bd4424bb (diff)
downloadcoreutils-c768e2231b89901a2e29c3bf96c027b64f8646d9.tar.xz
mktemp: fix bug with -q and closed stdout
If stdin or stdout is closed, then freopen(,stderr) can violate the premise that STDERR_FILENO==fileno(stderr), which in turn breaks mktemp -q. * bootstrap.conf (gnulib_modules): Add freopen-safer. * src/mktemp.c (includes): Use stdio--.h. * tests/misc/close-stdout: Enhance test to catch bug.
Diffstat (limited to 'tests/misc/close-stdout')
-rwxr-xr-xtests/misc/close-stdout6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout
index 852c3c822..ae2350dce 100755
--- a/tests/misc/close-stdout
+++ b/tests/misc/close-stdout
@@ -52,7 +52,8 @@ if "$p/src/test" -w /dev/stdout >/dev/null &&
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
+ mktemp tmpfile-XXXXXX -q >&- 2>/dev/null && fail=1
+ case `echo tmpfile-??????` in 'tmpfile-??????') ;; *) fail=1 ;; esac
fi
# Likewise for /dev/full, if /dev/full works.
@@ -61,7 +62,8 @@ if test -w /dev/full && test -c /dev/full; then
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
+ mktemp -d -q tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1
+ case `echo tmpfile-??????` in 'tmpfile-??????') ;; *) fail=1 ;; esac
fi
Exit $fail