Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: coproc problem when input closed but output open
Thanks.
On Wed, 16 Mar 2011, Bart Schaefer wrote:
> You still have "cat <&6 &" running in the background. That has a copy of
> the coproc's stdin (fd5) open, because it inherited all the descriptors
> of the parent shell and fd5 is not specially closed the way the "p"
> descriptor is. You can use
>
> cat <&6 5>&- &
>
> to be sure cat doesn't inherit fd5.
>
> It might be clearer if you restructure the code to be:
>
> coproc wcFunc
> wcf=$!
>
> # copy output of coproc to stdout
> cat <&p &
>
> # copy the write and read fd's for the coproc
> exec 5>&p 6<&p
> exec 6<&-
>
> # start another null coproc to get a new target for the p fd
> coproc exit
>
> Then you don't need to fiddle with fd5 when starting the cat.
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author