On 6/3/12 8:20 AM, Davide Baldini wrote: > Machine: i486 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -O2 -march='i486' (plus the flags added by Makefile) > uname output: Linux debianBunker 2.6.26-2-686 #1 SMP Wed Sep 21 04:35:47 > UTC 2011 i686 GNU/Linux > Machine Type: i486-pc-linux-gnu > > Bash Version: 4.2.0(5)-release > Patch Level: 5 > Release Status: release > > Description: > In the following test script I run an elementary coprocess to which the > echo built-in, run in background, attaches its standard-output: > > #!/bin/bash > # TEST 1 > coproc /bin/sleep 100 > echo >&${COPROC[1]} & > > The script always fails, for no apparent reason, giving the output: > > ./test.sh: line 4: ${COPROC[1]}: Bad file descriptor
Coproc file descriptors are not available to subshells. They're implemented using pipes, and leaving pipe file descriptors open in subshells causes processes to hang and not terminate properly, which results in very hard-to-track-down-and-reproduce bugs. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/