From 9b430e0e8deaf5a2dd70c8d426f6b18d05cd6c15 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Tue, 29 Jun 2021 13:20:16 +0200
Subject: [PATCH 16/34] input: give up on the input stream only after millions
 of errors

This mitigates a problem seen sometimes among the Red Hat crash reports:
somehow wgetch() keeps returning ERR, as if it were in nodelay mode.
(I've seen this happen once after nano came out of suspension.)

Using a much larger error-count value gives the user a few seconds
to type something and hopefully get out of the error condition.
---
 src/winio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/winio.c b/src/winio.c
index 17ac9dad..d841bee0 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -197,11 +197,11 @@ void read_keys_from(WINDOW *win)
 			input = KEY_WINCH;
 		}
 #endif
-		/* When we've failed to get a keycode over a hundred times in a row,
+		/* When we've failed to get a keycode millions of times in a row,
 		 * assume our input source is gone and die gracefully.  We could
 		 * check if errno is set to EIO ("Input/output error") and die in
 		 * that case, but it's not always set properly.  Argh. */
-		if (input == ERR && ++errcount == 123)
+		if (input == ERR && ++errcount == 12345678)
 			die(_("Too many errors from stdin\n"));
 	}
 
-- 
2.29.3

