From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6161 invoked from network); 17 May 2009 21:48:41 -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 21:48:41 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 16101 invoked from network); 17 May 2009 21:48:28 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 May 2009 21:48:28 -0000 Received: (qmail 517 invoked by alias); 17 May 2009 21:48:10 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 14127 Received: (qmail 499 invoked from network); 17 May 2009 21:48:09 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 17 May 2009 21:48:09 -0000 Received: from vms173009pub.verizon.net (vms173009pub.verizon.net [206.46.173.9]) by bifrost.dotsrc.org (Postfix) with ESMTP id 3285D801E289 for ; Sun, 17 May 2009 23:48:05 +0200 (CEST) Received: from torch.brasslantern.com ([96.249.201.13]) by vms173009.mailsrvcs.net (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPA id <0KJT00L7S5VPL91W@vms173009.mailsrvcs.net> for zsh-users@sunsite.dk; Sun, 17 May 2009 16:47:54 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id n4HLlm0L000961 for ; Sun, 17 May 2009 14:47:49 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id n4HLllZo000960 for zsh-users@sunsite.dk; Sun, 17 May 2009 14:47:47 -0700 From: Bart Schaefer Message-id: <090517144747.ZM959@torch.brasslantern.com> Date: Sun, 17 May 2009 14:47:47 -0700 In-reply-to: <20090517044323.15333.qmail@smasher.org> Comments: In reply to Atom Smasher "runaway zselect" (May 17, 4:43pm) References: <20090517044323.15333.qmail@smasher.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@sunsite.dk Subject: Re: runaway zselect MIME-version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: ClamAV 0.94.2/9365/Sat May 16 14:41:29 2009 on bifrost X-Virus-Status: Clean 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 )