From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22610 invoked from network); 17 May 2009 23:29:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 17 May 2009 23:29:33 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 43814 invoked from network); 17 May 2009 23:29:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 May 2009 23:29:20 -0000 Received: (qmail 16006 invoked by alias); 17 May 2009 23:29:03 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14128 Received: (qmail 15996 invoked from network); 17 May 2009 23:29:02 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 17 May 2009 23:29:02 -0000 Received: from atom.smasher.org (atom.smasher.org [69.55.237.145]) by bifrost.dotsrc.org (Postfix) with SMTP id 48311801E289 for ; Mon, 18 May 2009 01:28:57 +0200 (CEST) Received: (qmail 6095 invoked by uid 1000); 17 May 2009 23:28:56 -0000 Message-ID: <20090517232856.6093.qmail@smasher.org> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Date: Mon, 18 May 2009 11:28:55 +1200 (NZST) From: Atom Smasher In-Reply-To: <090517144747.ZM959@torch.brasslantern.com> MIME-Version: 1.0 OpenPGP: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt References: <20090517044323.15333.qmail@smasher.org> <090517144747.ZM959@torch.brasslantern.com> Subject: Re: runaway zselect To: zsh-users@sunsite.dk X-POM: The Moon is Waning Crescent (44% of Full) X-Hashcash: 1:20:0905172328:zsh-users@sunsite.dk::KNT/6hGfE7NbaSzf:0000000000000 0000000000000000000000001Xzq X-Virus-Scanned: ClamAV 0.94.2/9365/Sat May 16 14:41:29 2009 on bifrost X-Virus-Status: Clean cool... thanks! On Sun, 17 May 2009, Bart Schaefer wrote: > On May 17, 4:43pm, Atom Smasher wrote: > } > } i would expect zselect to return an error and stop the while loop when > } "w" stops producing output. > > That's not how the select() system call works. The descriptor is still > open on the reading end of the pipe even though the descriptor on the > writing end of the pipe has been closed. That means from select()'s > point of view, the descriptor is available for reading, even though the > only thing that can be read from it is the end-of-file condition. > > If this were not the case, zselect would fail as soon as the writer > exits, even if all output from the writer had not yet been consumed. > (Remember that there is OS-level buffering involved, so the writing end > may be closed before the pipe is "empty".) > > What you need to fix this is to test the result of "read" as well. > Either: > > while zselect -r 0 && read -r foo > do > print -r -- $foo > done <<( w ) > > Or equivalently: > > while zselect -r 0 > do > read -r foo || break > print -r -- $foo > done <<( w ) > > -- ...atom ________________________ http://atom.smasher.org/ 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808 ------------------------------------------------- "I am committed to helping Ohio deliver its electoral votes to the president [Bush] next year" -- Walden O'Dell, CEO of Diebold August 2003