summary refs log tree commit diff
path: root/bin/cash/tests/execution/redir2.0
blob: af30fb0936b3fe52fff50949139e0ff34b3ee04a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# $FreeBSD: releng/12.0/bin/sh/tests/execution/redir2.0 213738 2010-10-12 18:20:38Z obrien $
trap ': $((brokenpipe+=1))' PIPE

P=${TMPDIR:-/tmp}
cd $P
T=$(mktemp -d sh-test.XXXXXX)
cd $T

brokenpipe=0
mkfifo fifo1 fifo2
{
	{
		exec ${SH} -c 'exec <fifo1; read dummy'
	} 7<&- # fifo2 should be kept open, but not passed to programs
	true
} 7<fifo2 &

exec 4>fifo2
exec 3>fifo1
echo dummy >&4 2>/dev/null
if [ $brokenpipe -eq 1 ]; then
	: ${rc:=0}
fi
echo dummy >&3
wait

rm fifo1 fifo2
rmdir ${P}/${T}
exit ${rc:-3}