bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redirect a backgrounded process' stdout toward COPROC's stdin


From: Chet Ramey
Subject: Re: Redirect a backgrounded process' stdout toward COPROC's stdin
Date: Mon, 04 Jun 2012 09:12:56 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

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    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]