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

coproc problem when input closed but output open



Thanks for the tip involving calling coproc exit at the begnning of a 
coproc shell function, I think using coproc that way is really useful.

Now I'm having trouble with another example, where the coproc doesn't 
return without killing it.  Maybe the problem has something to do with the 
output file descriptor of the coproc still being open.  But shouldn't the 
coproc finish writing its output and exit?

Thanks,
Rory M.

 function wcFunc() {
    coproc exit	 
    wc
  }

  coproc wcFunc
  wcf=$!
  # copy the write and read fd's for the coproc
  exec 5>&p 6<&p
  # start another null coproc to get a new target for the p fd
  coproc exit

  # copy output of coproc to stdout
  cat <&6 &
  exec 6<&-

  echo hi there >&5
  # close the fd, so hopefully the coproc would exit, but it doesn't
  exec 5>&-



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