xref: /freebsd/bin/sh/tests/execution/redir1.0 (revision ab393e9548f8cc0ee28499c411963b798ebb38a5)
1trap ': $((brokenpipe+=1))' PIPE
2
3P=${TMPDIR:-/tmp}
4cd $P
5T=$(mktemp -d sh-test.XXXXXX)
6cd $T
7
8brokenpipe=0
9mkfifo fifo1 fifo2
10read dummy >fifo2 <fifo1 &
11{
12	exec 4>fifo2
13} 3<fifo2 # Formerly, sh would keep fd 3 and a duplicate of it open.
14echo dummy >fifo1
15if [ $brokenpipe -ne 0 ]; then
16	rc=3
17fi
18wait
19echo dummy >&4 2>/dev/null
20if [ $brokenpipe -eq 1 ]; then
21	: ${rc:=0}
22fi
23
24rm fifo1 fifo2
25rmdir ${P}/${T}
26exit ${rc:-3}
27