Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: coproc fd leak leading to possible deadlock



On Wed, Mar 06, 2013 at 10:53:41PM +0000, Stephane Chazelas wrote:
> Side question: is it possible to close any of the coproc pipes?
> >&p- or <&p- don't work.
> 
> If I run another coproc, that closes the current one AFAICT, so I
> can do:
> 
> coproc cmd
> exec {i}<&p {o}>&p
> coproc :
> exec {i}<&-
Interesting, I'm glad to know this. Thanks.
> 
> as a work around, but I thought there should be a simpler way.
> 
> Even when the coproc has terminated, the fds are not closed.
> 
> sc% coproc sleep 10
> [1] 14594
> sc% lsof -ad11-20 -p $$
> COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
> zsh     12148 chazelas   11r  FIFO    0,8      0t0 295967 pipe
> zsh     12148 chazelas   14w  FIFO    0,8      0t0 295968 pipe
> sc%
> [1]  + done       sleep 10
> sc% lsof -ad11-20 -p $$
> COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
> zsh     12148 chazelas   11r  FIFO    0,8      0t0 295967 pipe
> zsh     12148 chazelas   14w  FIFO    0,8      0t0 295968 pipe
> 
> Having said that, zsh coproc is a lot more usable that bash's or ksh's. At
> least the issues can easily be worked around.
> 
> -- 
> Stephane



Messages sorted by: Reverse Date, Date, Thread, Author