zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-users@zsh.org>
Subject: Re: strange behavior
Date: Mon, 11 Apr 2011 16:15:27 +0100	[thread overview]
Message-ID: <20110411161527.1ce7988c@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20110411143930.GA27818@prunille.vinc17.org>

On Mon, 11 Apr 2011 16:39:30 +0200
Vincent Lefevre <vincent@vinc17.org> 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 <pws@csr.com>            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


  reply	other threads:[~2011-04-11 15:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-02 12:09 Vincent Lefevre
2010-11-15 16:32 ` Vincent Lefevre
2010-11-15 17:24   ` Bart Schaefer
2010-11-16  3:10     ` Vincent Lefevre
2011-01-28 14:44       ` Vincent Lefevre
2011-01-28 15:49         ` Bart Schaefer
2011-01-30  0:37           ` Vincent Lefevre
2011-01-30 22:25             ` Bart Schaefer
2011-01-31  9:11               ` Vincent Lefevre
2011-04-11 14:26               ` Vincent Lefevre
2011-04-11 14:39                 ` Vincent Lefevre
2011-04-11 15:15                   ` Peter Stephenson [this message]
2011-04-28 11:32                     ` Vincent Lefevre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110411161527.1ce7988c@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).