On 10/2/20 7:59 AM, Hyunho Cho wrote:

> bash$ ( echo "1 + 5" >& ${COPROC[1]}; read -r <& ${COPROC[0]}; echo
> $REPLY )                  # ERROR : subshell does not work
> bash: ${COPROC[1]}: Bad file descriptor
> bash: ${COPROC[0]}: Bad file descriptor
> 3

Yes, this is correct. Subshells close coproc file descriptors they inherit.
This is to prevent deadlock and processes not terminating because there are
still open file descriptors to child processes. If you want to manage the
file descriptors yourself, you can dup the coproc file descriptors and make
sure they're closed appropriately for your needs.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to