Zsh Mailing List Archive
Messages sorted by:
Re: exit value of intermediate program in pipe
- X-seq: zsh-users 1506
- From: Bernd Eggink <eggink@xxxxxxxxxxxxxx>
- To: Sweth Chandramouli <sweth@xxxxxxxxxxxxxxxxxxxx>
- Subject: Re: exit value of intermediate program in pipe
- Date: Mon, 04 May 1998 11:43:27 +0200
- Cc: zsh-users@xxxxxxxxxxxxxxx
- Organization: RRZ Uni Hamburg
- References: <199805022224.QAA03113@xxxxxxxxxxxxxxxxxxxxxx> <980502190831.ZM29269@xxxxxxxxxxxxxxxxxxxxxxx> <19980503021749.21621@xxxxxxxxxxxxxxxxxxxx> <980503023014.ZM31001@xxxxxxxxxxxxxxxxxxxxxxx> <19980503181509.09250@xxxxxxxxxxxxxxxxxxxx> <980503183549.ZM1342@xxxxxxxxxxxxxxxxxxxxxxx> <19980504005404.54023@xxxxxxxxxxxxxxxxxxxx>
- Sender: rz2a022@xxxxxxxxxxxxxx
Sweth Chandramouli wrote:
> > The last problem is that grep won't exit until it sees EOF on its stdin,
> > but >&p dups the coproc input without actually closing it. So the grep
> > won't get EOF when blah exits. You have to shut it down some other way;
> > the only thing I've found is to start another coprocess. I don't know
> > if this is a bug, or what.
> at first, i wasn't sure if this would be a bug or not; it would
> make some conceptual sense to have a "coprocess exit" command that closed
> out a coprocess, and when i tried to find some docs on coproc, all i could
> find was the fmli coproc, which uses a similar cocreate/codestroy metaphor.
> as far as i can tell, though, zsh coproc just swallows the eof, since doing
> echo "^D" >&p
> should otherwise have the same effect as "coproc exit", but doesn't. and
> _that_ is something that i _would_ consider a bug.
In ksh, the normal way to kill a coproc is
exec 3<&p 3<-
because just killing the job doesn't close the file descriptor. In
zsh-3.1.3, this doesn't work (a bug, IMHO), but you can kill the job
without getting problems.
> does this mean that you can only have one coproc open at a
> time? i could see situations where it might be useful to have more
> than one coproc open at once, rather than opening and closing the
> same two executables over and over in rapid succession.
You can have more than one coprocs at a time. Just copy the fd's:
exec 3>&p 4<&p # or whatever numbers you like
Now you can communicate with f and g separately:
print -u3 "to f"
read -u4 x # from f
print -p "to g"
read -p y # from g
Regionales Rechenzentrum der Uni Hamburg
Messages sorted by: