about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2000-05-19 15:10:52 +0000
committerBart Schaefer <barts@users.sourceforge.net>2000-05-19 15:10:52 +0000
commit529158f82f1959019c21c0d6e7081a6dae677401 (patch)
tree4870ca091a7246edd15cdb866ccde9feba7ffe51
parent7672efed2e75e70fd9dbe0c51ef661622f5e5091 (diff)
downloadzsh-529158f82f1959019c21c0d6e7081a6dae677401.tar.gz
zsh-529158f82f1959019c21c0d6e7081a6dae677401.tar.xz
zsh-529158f82f1959019c21c0d6e7081a6dae677401.zip
11461: Make "read" interruptible even when used in the tail of a pipeline.
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c15
2 files changed, 16 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 11de2d23d..1026efa63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-05-19  Bart Schaefer  <schaefer@zsh.org>
+
+	* 11461: Src/builtin.c: Make "read" interruptible even when used
+	in the tail of a pipeline.
+
 2000-05-19  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 11466: Src/Zle/compresult.c: fix for unambiguous string insertion
diff --git a/Src/builtin.c b/Src/builtin.c
index 24b60fb30..92ab41454 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3536,6 +3536,7 @@ bin_read(char *name, char **args, char *ops, int func)
     first = 1;
     bslash = 0;
     while (*args || (ops['A'] && !gotnl)) {
+	sigset_t s = child_unblock();
 	buf = bptr = (char *)zalloc(bsiz = 64);
 	/* get input, a character at a time */
 	while (!gotnl) {
@@ -3573,6 +3574,7 @@ bin_read(char *name, char **args, char *ops, int func)
 		bptr = buf + blen;
 	    }
 	}
+	signal_setmask(s);
 	if (c == '\n' || c == EOF)
 	    gotnl = 1;
 	*bptr = '\0';
@@ -3627,7 +3629,8 @@ bin_read(char *name, char **args, char *ops, int func)
     buf = bptr = (char *)zalloc(bsiz = 64);
     /* any remaining part of the line goes into one parameter */
     bslash = 0;
-    if (!gotnl)
+    if (!gotnl) {
+	sigset_t s = child_unblock();
 	for (;;) {
 	    c = zread(izle);
 	    /* \ at the end of a line introduces a continuation line, except in
@@ -3662,6 +3665,8 @@ bin_read(char *name, char **args, char *ops, int func)
 		bptr = buf + blen;
 	    }
 	}
+	signal_setmask(s);
+    }
     while (bptr > buf && iwsep(bptr[-1]))
 	bptr--;
     *bptr = '\0';
@@ -3718,8 +3723,8 @@ zread(int izle)
 	case 1:
 	    /* return the character read */
 	    return STOUC(cc);
-#if defined(EAGAIN) || defined(EWOULDBLOCK)
 	case -1:
+#if defined(EAGAIN) || defined(EWOULDBLOCK)
 	    if (!retry && readfd == 0 && (
 # ifdef EAGAIN
 		    errno == EAGAIN
@@ -3733,9 +3738,11 @@ zread(int izle)
 		) && setblock_stdin()) {
 		retry = 1;
 		continue;
-	    }
-	    break;
+	    } else
 #endif /* EAGAIN || EWOULDBLOCK */
+	    if (errno == EINTR && !(errflag || retflag || breaks || contflag))
+		continue;
+	    break;
 	}
 	return EOF;
     }