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

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