If I run
$#/bin/bash
for i in `seq 5`; do
exec 3> >(sed -e \"s/^/$i: /\"; echo \"$i-\")
echo foo >&3
echo bar >&3
exec 3&
The "obvious" answer is to get rid of the process substitution.
for i in `seq 5`; do
echo foo | sed -e "s/^/$i: /"; echo "$i-"
echo bar | sed -e "s/^/$i: /"; echo "$i-"
done
So the question becomes, do you really need to structure your code using process substitution? The above is much simpler than trying to synchronize an asynchronous construct.