From 38f6438b72e6dba67bd6f6c5e2bef4b53a179b30 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 18 Nov 1993 09:45:27 +0000 Subject: [PATCH] (read_avail_input): Don't set nread to -1 if we loop around in the loop that calls read. --- src/keyboard.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 47092b339fe..7a0e2fa1f17 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -3059,23 +3059,26 @@ read_avail_input (expected) /* Now read; for one reason or another, this will not block. */ while (1) { - nread = read (fileno (stdin), cbuf, nread); + int value = read (fileno (stdin), cbuf, nread); #ifdef AIX /* The kernel sometimes fails to deliver SIGHUP for ptys. This looks incorrect, but it isn't, because _BSD causes O_NDELAY to be defined in fcntl.h as O_NONBLOCK, and that causes a value other than 0 when there is no input. */ - if (nread == 0) + if (value == 0) kill (SIGHUP, 0); #endif /* Retry the read if it is interrupted. */ - if (nread >= 0 + if (value >= 0 || ! (errno == EAGAIN || errno == EFAULT #ifdef EBADSLT || errno == EBADSLT #endif )) - break; + { + nread = value; + break; + } } #ifndef FIONREAD -- 2.39.5