diff --git a/src/redis-cli.c b/src/redis-cli.c index e363a2795..db53fc7d8 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -6724,6 +6724,7 @@ static void pipeMode(void) { /* Handle the readable state: we can read replies from the server. */ if (mask & AE_READABLE) { ssize_t nread; + int read_error = 0; /* Read from socket and feed the hiredis reader. */ do { @@ -6731,7 +6732,8 @@ static void pipeMode(void) { if (nread == -1 && errno != EAGAIN && errno != EINTR) { fprintf(stderr, "Error reading from the server: %s\n", strerror(errno)); - exit(1); + read_error = 1; + break; } if (nread > 0) { redisReaderFeed(reader,ibuf,nread); @@ -6764,6 +6766,11 @@ static void pipeMode(void) { freeReplyObject(reply); } } while(reply); + + /* Abort on read errors. We abort here because it is important + * to consume replies even after a read error: this way we can + * show a potential problem to the user. */ + if (read_error) exit(1); } /* Handle the writable state: we can send protocol to the server. */