COPROC
Articles
Example
Run a "bc" in a subshell and keep it running to call multiple times from a loop without the overhead to instantiate "bc" every single iteration.
coproc stdbuf -o0 sed 's/.*/msg: &/'
for i in {1..10}
do
echo $i >&${COPROC[1]}
read -u ${COPROC[0]} rc
echo $rc
done
kill $COPROC_PID
OUTPUT
msg: 1 msg: 2 msg: 3 msg: 4 msg: 5 msg: 6 msg: 7 msg: 8 msg: 9 msg: 10