projects
/
apps
/
madtty.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
57358ec
)
Limited number of iterations in rote_vt_update to avoid infinite loop with ever-avail...
author
btakahashi
<btakahashi>
Tue, 10 May 2005 00:00:17 +0000
(
00:00
+0000)
committer
btakahashi
<btakahashi>
Tue, 10 May 2005 00:00:17 +0000
(
00:00
+0000)
rote.c
patch
|
blob
|
history
diff --git
a/rote.c
b/rote.c
index
19ec25d
..
322e8eb
100644
(file)
--- a/
rote.c
+++ b/
rote.c
@@
-26,6
+26,8
@@
Copyright (c) 2004 Bruno T. C. de Oliveira
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
+#define ROTE_VT_UPDATE_ITERATIONS 5
+
RoteTerm *rote_vt_create(int rows, int cols) {
RoteTerm *rt;
int i, j;
RoteTerm *rote_vt_create(int rows, int cols) {
RoteTerm *rt;
int i, j;
@@
-158,9
+160,17
@@
void rote_vt_update(RoteTerm *rt) {
struct timeval tvzero;
char buf[512];
int bytesread;
struct timeval tvzero;
char buf[512];
int bytesread;
+ int n = ROTE_VT_UPDATE_ITERATIONS;
if (rt->pd->pty < 0) return; /* nothing to pump */
if (rt->pd->pty < 0) return; /* nothing to pump */
- while (1) {
+ 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;
/* check if pty has something to say */
FD_ZERO(&ifs); FD_SET(rt->pd->pty, &ifs);
tvzero.tv_sec = 0; tvzero.tv_usec = 0;