From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10797 invoked from network); 18 Oct 2000 11:31:06 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Oct 2000 11:31:06 -0000 Received: (qmail 29594 invoked by alias); 18 Oct 2000 11:31:00 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13024 Received: (qmail 29583 invoked from network); 18 Oct 2000 11:30:59 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Zsh hackers list" Subject: PATCH: ptyread eating CPU on Cygwin Date: Wed, 18 Oct 2000 15:30:55 +0400 Message-ID: <001301c038f6$e114c940$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0014_01C03918.68266940" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal In-Reply-To: <0G2M00BKYBW8I7@la-la.cambridgesiliconradio.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C03918.68266940 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit > > The problem I was having was with putting the terminal temporarily into raw > mode without the full majesty of zle and setting a timeout there (in > bin_read()). select is working fine in the main terminal code. I didn't > have the week necessary to resolve all the possible ways of setting > timeouts, so I gave up. I expect it can be done. > O.K., this is very simple patch that makes ptyread use select. Sven, could you look at conditions there? It should be O.K. (blocking select can return either positive value or -1 if interrupted, in which case we simply exit read loop). With this patch 'make check' has acceptable CPU load. Attached due to line length. -andrej ------=_NextPart_000_0014_01C03918.68266940 Content-Type: application/octet-stream; name="zsh-zpty.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zsh-zpty.diff" Index: Src/Modules/zpty.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/Modules/zpty.c,v=0A= retrieving revision 1.11=0A= diff -u -r1.11 zpty.c=0A= --- Src/Modules/zpty.c 2000/06/27 14:25:05 1.11=0A= +++ Src/Modules/zpty.c 2000/10/18 11:26:20=0A= @@ -446,6 +446,9 @@=0A= int blen =3D 256, used =3D 0, ret =3D 1;=0A= char *buf =3D (char *) zhalloc(blen + 1);=0A= Patprog prog =3D NULL;=0A= +#ifdef HAVE_SELECT=0A= + fd_set foofd;=0A= +#endif=0A= =0A= if (*args && args[1]) {=0A= char *p;=0A= @@ -468,7 +471,16 @@=0A= if (cmd->fin)=0A= break;=0A= }=0A= - if ((ret =3D read(cmd->fd, buf + used, 1)) =3D=3D 1) {=0A= +#ifdef HAVE_SELECT=0A= + FD_ZERO(&foofd);=0A= + FD_SET(cmd->fd, &foofd);=0A= +#endif=0A= + if (=0A= +#ifdef HAVE_SELECT=0A= + (ret =3D select(cmd->fd+1, (SELECT_ARG_2_T) &foofd, NULL, NULL, = NULL) > 0) &&=0A= +#endif=0A= +=0A= + (ret =3D read(cmd->fd, buf + used, 1)) =3D=3D 1) {=0A= if (++used =3D=3D blen) {=0A= buf =3D hrealloc(buf, blen, blen << 1);=0A= blen <<=3D 1;=0A= ------=_NextPart_000_0014_01C03918.68266940--