Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: strange behavior
On Mon, 11 Apr 2011 16:39:30 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> 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@xxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author