From: Rory Mulvaney <rory1@umbc.edu>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@zsh.org
Subject: Re: coproc problem when input closed but output open
Date: Thu, 17 Mar 2011 16:17:19 -0500 (CDT) [thread overview]
Message-ID: <alpine.DEB.2.00.1103171605160.356@MyComp.rgm-web.net> (raw)
In-Reply-To: <110316075735.ZM19183@torch.brasslantern.com>
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.
>
prev parent reply other threads:[~2011-03-17 21:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-15 19:04 Rory Mulvaney
2011-03-16 14:57 ` Bart Schaefer
2011-03-17 21:17 ` Rory Mulvaney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.1103171605160.356@MyComp.rgm-web.net \
--to=rory1@umbc.edu \
--cc=schaefer@brasslantern.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).