#!/bin/bash
dir=$PWD
work_dir="$dir/.net.$$"
trap "kill -TERM -$$ 2>/dev/null; trap - EXIT; find '$work_dir' -type p | xa rm -f ; rmdir '$work_dir'; exit" HUP INT QUIT TERM PIPE EXIT
mkdir	"$work_dir"
cd	"$work_dir"
# usage: test-catb [catb|cat]
#   use 'cat' to show deadlock
cat=${1:-catb}
mkfifo big_pipe_1 big_pipe_2
find /etc/ | tee big_pipe_2 >big_pipe_1 &
$cat big_pipe_1 big_pipe_2 | wc -l &
wait
rm -f big_pipe_1 big_pipe_2
