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