From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13626 invoked by alias); 11 Apr 2011 15:15:46 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15953 Received: (qmail 13421 invoked from network); 11 Apr 2011 15:15:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 11 Apr 2011 16:15:27 +0100 From: Peter Stephenson To: Subject: Re: strange behavior Message-ID: <20110411161527.1ce7988c@pwslap01u.europe.root.pri> In-Reply-To: <20110411143930.GA27818@prunille.vinc17.org> References: <20101102120943.GK19295@prunille.vinc17.org> <20101115163234.GE19451@prunille.vinc17.org> <101115092438.ZM29576@torch.brasslantern.com> <20101116031023.GF19451@prunille.vinc17.org> <20110128144412.GA22306@ypig.lip.ens-lyon.fr> <110128074915.ZM5855@torch.brasslantern.com> <20110130003731.GL15921@prunille.vinc17.org> <110130142540.ZM15672@torch.brasslantern.com> <20110411142618.GA19503@ypig.lip.ens-lyon.fr> <20110411143930.GA27818@prunille.vinc17.org> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.103.11.49] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.113 On Mon, 11 Apr 2011 16:39:30 +0200 Vincent Lefevre wrote: > and this is because the SIGWINCH seems to interrupt the "read" > (is it a bug?), so that > > while read -r $timeout -k -u 0 ch > do > line="$line$ch" > [[ $ch = $'\012' ]] && break > timeout=(-t 0.1) > done > > gives an empty string; hence the observed behavior. Yes, we handle EINTR in most places and should do so here. There are lots of nasty special cases in bin_read(); I think this is this one. Index: Src/builtin.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v retrieving revision 1.249 diff -p -u -r1.249 builtin.c --- Src/builtin.c 4 Mar 2011 13:25:26 -0000 1.249 +++ Src/builtin.c 11 Apr 2011 15:13:19 -0000 @@ -5291,9 +5291,16 @@ bin_read(char *name, char **args, Option *bptr = readchar; val = 1; readchar = -1; - } else if ((val = read(readfd, bptr, nchars)) <= 0) { - eof = 1; - break; + } else { + while ((val = read(readfd, bptr, nchars)) < 0) { + if (errno != EINTR || + errflag || retflag || breaks || contflag) + break; + } + if (val <= 0) { + eof = 1; + break; + } } #ifdef MULTIBYTE_SUPPORT -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom