-#endif
-
-void rote_vt_update(RoteTerm *rt) {
- fd_set ifs;
- struct timeval tvzero;
- char buf[512];
- int bytesread;
- int n = ROTE_VT_UPDATE_ITERATIONS;
- if (rt->pd->pty < 0) return; /* nothing to pump */
-
- while (n--) { /* iterate at most ROVE_VT_UPDATE_ITERATIONS times.
- * As Phil Endecott pointed out, if we don't restrict this,
- * a program that floods the terminal with output
- * could cause this loop to iterate forever, never
- * being able to catch up. So we'll rely on the client
- * calling rote_vt_update often, as the documentation
- * recommends :-) */
-
- /* check if pty has something to say */
- FD_ZERO(&ifs); FD_SET(rt->pd->pty, &ifs);
- tvzero.tv_sec = 0; tvzero.tv_usec = 0;
-
- if (select(rt->pd->pty + 1, &ifs, NULL, NULL, &tvzero) <= 0)
- return; /* nothing to read, or select() failed */
-
- /* read what we can. This is guaranteed not to block, since
- * select() told us there was something to read. */
- bytesread = read(rt->pd->pty, buf, 512);
- if (bytesread <= 0) return;
-
- /* inject the data into the terminal */
- rote_vt_inject(rt, buf, bytesread);
- }
+void rote_vt_update(RoteTerm *rt)
+{
+ char buf[512];
+ int nbread;
+ int n = ROTE_VT_UPDATE_ITERATIONS;
+
+ while (n--) { /* iterate at most ROVE_VT_UPDATE_ITERATIONS times.
+ * As Phil Endecott pointed out, if we don't restrict this,
+ * a program that floods the terminal with output
+ * could cause this loop to iterate forever, never
+ * being able to catch up. So we'll rely on the client
+ * calling rote_vt_update often, as the documentation
+ * recommends :-) */
+
+ nbread = rote_vt_read(rt, buf, sizeof(buf));
+ if (nbread <= 0)
+ return;
+
+ /* inject the data into the terminal */
+ rote_vt_inject(rt, buf, nbread);
+ }