# Patch #1 for c3270 3.2.19.  Coorrects c3270's behavior when it encounters
# end-of-file on standard input.

--- screen.c.orig	Thu Jul 18 14:26:26 2002
+++ screen.c	Thu Jul 18 14:24:24 2002
@@ -29,6 +29,7 @@
 #include "tablesc.h"
 #include "trace_dsc.h"
 #include "utilc.h"
+#include "xioc.h"
 
 #undef COLS
 extern int cCOLS;
@@ -412,6 +413,8 @@
 kybd_input(void)
 {
 	int k;
+	Boolean first = True;
+	static Boolean failed_first = False;
 
 	for (;;) {
 		Boolean derived = False;
@@ -419,8 +422,18 @@
 		if (isendwin())
 			return;
 		k = wgetch(stdscr);
-		if (k == ERR)
+		if (k == ERR) {
+			if (first) {
+				if (failed_first) {
+					trace_event("End of File, exiting.\n");
+					x3270_exit(1);
+				}
+				failed_first = True;
+			}
 			return;
+		} else {
+			failed_first = False;
+		}
 		trace_event("Key %s (0x%x)\n", decode_key(k, 0), k);
 
 		/* Handle Meta-Escapes. */
@@ -438,6 +451,7 @@
 			continue;
 		}
 		kybd_input2(k, derived);
+		first = False;
 	}
 }
 
