Ttyread() calls to ttywrite, so if we check for reading before
that for writing in ttywrite we can get a circular call sequence.
                                continue;
                        die("select failed: %s\n", strerror(errno));
                }
                                continue;
                        die("select failed: %s\n", strerror(errno));
                }
-               if (FD_ISSET(cmdfd, &rfd))
-                       lim = ttyread();
                if (FD_ISSET(cmdfd, &wfd)) {
                        /*
                         * Only write the bytes written by ttywrite() or the
                if (FD_ISSET(cmdfd, &wfd)) {
                        /*
                         * Only write the bytes written by ttywrite() or the
 
+               if (FD_ISSET(cmdfd, &rfd))
+                       lim = ttyread();