2 # Ensure that several programs work fine, even with stdout initially closed.
3 # This is effectively a test of closeout.c's close_stdout function.
5 if test "$VERBOSE" = yes; then
11 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
12 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
13 trap '(exit $?); exit $?' 1 2 13 15
16 mkdir -p $tmp || framework_failure=1
17 cd $tmp || framework_failure=1
19 if test $framework_failure = 1; then
20 echo "$0: failure in testing framework" 1>&2
24 PATH="$pwd/../..:$PATH"
29 # Ensure these exit successfully, even though stdout is closed,
30 # because they generate no output.
34 chmod o-w . >&- || fail=1
42 $pwd/../../src/true >&- || fail=1
43 $pwd/../../src/printf '' >&- || fail=1
45 # If >&- works, ensure these fail, because stdout is closed and they
46 # *do* generate output. >&- apparently does not work in HP-UX 11.23.
47 # This test is ineffective unless /dev/stdout also works.
48 if $pwd/../../src/test -w /dev/stdout >/dev/null &&
49 $pwd/../../src/test ! -w /dev/stdout >&-; then
50 $pwd/../../src/printf 'foo' >&- 2>/dev/null && fail=1
51 cp --verbose a b >&- 2>/dev/null && fail=1
54 # Likewise for /dev/full, if /dev/full works.
55 if test -w /dev/full && test -c /dev/full; then
56 $pwd/../../src/printf 'foo' >/dev/full 2>/dev/null && fail=1
57 cp --verbose a b >/dev/full 2>/dev/null && fail=1
60 (exit $fail); exit $fail