Blame SOURCES/telnet-0.17-pty-retry.patch

f3e6c7
--- a/telnetd/telnetd.c
f3e6c7
+++ b/telnetd/telnetd.c
f3e6c7
@@ -772,7 +772,6 @@ void telnet(int f, int p)
f3e6c7
     int on = 1;
f3e6c7
     char *HE;
f3e6c7
     const char *IM;
f3e6c7
-    int pty_read_ok = 0; /* track whether the pty read has worked yet */
f3e6c7
 
f3e6c7
     /*
f3e6c7
      * Initialize the slc mapping table.
f3e6c7
@@ -1086,19 +1085,24 @@ void telnet(int f, int p)
f3e6c7
 	 * Something to read from the pty...
f3e6c7
 	 */
f3e6c7
 	if (FD_ISSET(p, &ibits)) {
f3e6c7
+	    int eio = 0;
f3e6c7
+read_pty:
f3e6c7
 	    pcc = read(p, ptyibuf, BUFSIZ);
f3e6c7
-	    /*
f3e6c7
-	     * On some systems, if we try to read something
f3e6c7
-	     * off the master side before the slave side is
f3e6c7
-	     * opened, we get EIO.
f3e6c7
-	     */
f3e6c7
-	    if (pcc < 0 && (errno == EWOULDBLOCK || (errno == EIO && pty_read_ok == 0))) {
f3e6c7
+	    if (pcc < 0 && errno == EWOULDBLOCK) {
f3e6c7
 		pcc = 0;
f3e6c7
 	    } 
f3e6c7
+	    /*
f3e6c7
+	     * If we try to read something off the master side while the slave
f3e6c7
+	     * side is temporarily closed by login process, we get EIO.
f3e6c7
+	     */
f3e6c7
+	    else if (pcc < 0 && errno == EIO && eio < 1000) {
f3e6c7
+		    eio++;
f3e6c7
+		    poll(NULL, 0, 10);
f3e6c7
+		    goto read_pty;
f3e6c7
+	    }
f3e6c7
 	    else {
f3e6c7
 		if (pcc <= 0)
f3e6c7
 		    break;
f3e6c7
-		pty_read_ok = 1;	/* mark connection up for read */
f3e6c7
 #ifdef	LINEMODE
f3e6c7
 				/*
f3e6c7
 				 * If ioctl from pty, pass it through net