X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=rote.c;h=322e8eb18b6fac05bb0d090fc9fcfe56e085f37e;hb=7ea77f37c3d2ad6f176182e2b1441dd33e39af8c;hp=e6b6bda12773c29fff88319d79af72c73af8c2bc;hpb=93c516d8991c4b6935fc03a24317ea0785e78a93;p=apps%2Fmadtty.git diff --git a/rote.c b/rote.c index e6b6bda..322e8eb 100644 --- a/rote.c +++ b/rote.c @@ -1,3 +1,24 @@ +/* +LICENSE INFORMATION: +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License (LGPL) as published by the Free Software Foundation. + +Please refer to the COPYING file for more information. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Copyright (c) 2004 Bruno T. C. de Oliveira +*/ + + #include "rote.h" #include "roteprivate.h" #include @@ -5,6 +26,8 @@ #include #include +#define ROTE_VT_UPDATE_ITERATIONS 5 + RoteTerm *rote_vt_create(int rows, int cols) { RoteTerm *rt; int i, j; @@ -137,9 +160,17 @@ void rote_vt_update(RoteTerm *rt) { struct timeval tvzero; char buf[512]; int bytesread; + int n = ROTE_VT_UPDATE_ITERATIONS; 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;