From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14529 invoked from network); 4 May 1998 09:47:52 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 4 May 1998 09:47:52 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id FAA20457; Mon, 4 May 1998 05:43:11 -0400 (EDT) Resent-Date: Mon, 4 May 1998 05:42:59 -0400 (EDT) Sender: rz2a022@uni-hamburg.de Message-ID: <354D8DBF.F1F79617@rrz.uni-hamburg.de> Date: Mon, 04 May 1998 11:43:27 +0200 From: Bernd Eggink Organization: RRZ Uni Hamburg X-Mailer: Mozilla 4.04 [en] (X11; I; AIX 4.2) MIME-Version: 1.0 To: Sweth Chandramouli CC: zsh-users@math.gatech.edu Subject: Re: exit value of intermediate program in pipe References: <199805022224.QAA03113@ipecac.Central.Sun.COM> <980502190831.ZM29269@candle.brasslantern.com> <19980503021749.21621@astaroth.nit.gwu.edu> <980503023014.ZM31001@candle.brasslantern.com> <19980503181509.09250@astaroth.nit.gwu.edu> <980503183549.ZM1342@candle.brasslantern.com> <19980504005404.54023@astaroth.nit.gwu.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Resent-Message-ID: <"_wuo73.0.--4.YsOJr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1506 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 > an > 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: coproc f exec 3>&p 4<&p # or whatever numbers you like coproc g 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 Regards, Bernd -- Bernd Eggink Regionales Rechenzentrum der Uni Hamburg eggink@rrz.uni-hamburg.de http://www.rrz.uni-hamburg.de/eggink/BEggink.html