From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7525 invoked from network); 6 Sep 2002 11:34:02 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 6 Sep 2002 11:34:02 -0000 Received: (qmail 22621 invoked by alias); 6 Sep 2002 11:33:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17630 Received: (qmail 22605 invoked from network); 6 Sep 2002 11:33:55 -0000 Message-ID: <6134254DE87BD411908B00A0C99B044F041173D1@mowd019a.mow.siemens.ru> From: Borsenkow Andrej To: "'tvignaud@mandrakesoft.com'" Cc: "'Zsh hackers list'" Subject: Mandrake patch for "make it work on serial ports" Date: Fri, 6 Sep 2002 15:43:41 +0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C2559A.A6047630" This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C2559A.A6047630 Content-Type: text/plain The following patch is currently used on Mandrake (attached for zsh-workers). It basically always opens input in non-blocking mode. I am really interested to know when this patch is needed. Having open block on lack of carrier is perfectly sensible and long-adopted approach... Therry, I am sorry but I really had some problems and was away for quite some time. Thank you for making new release. -andrej ------_=_NextPart_000_01C2559A.A6047630 Content-Type: application/octet-stream; name="zsh-serial.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zsh-serial.patch" --- zsh-4.0.4/Src/builtin.c.open Tue Oct 16 02:49:17 2001=0A= +++ zsh-4.0.4/Src/builtin.c Wed May 15 11:55:32 2002=0A= @@ -3489,7 +3489,7 @@ bin_read(char *name, char **args, char *=0A= if (!zleactive) {=0A= if (SHTTY =3D=3D -1) {=0A= /* need to open /dev/tty specially */=0A= - if ((SHTTY =3D open("/dev/tty", O_RDWR|O_NOCTTY)) !=3D -1) {=0A= + if ((SHTTY =3D block_open("/dev/tty", O_RDWR|O_NOCTTY)) !=3D -1) = {=0A= haso =3D 1;=0A= oshout =3D shout;=0A= init_shout();=0A= --- zsh-4.0.4/Src/init.c.open Wed Oct 24 04:16:32 2001=0A= +++ zsh-4.0.4/Src/init.c Wed May 15 12:00:07 2002=0A= @@ -397,7 +397,7 @@ init_io(void)=0A= if (isatty(0)) {=0A= zsfree(ttystrname);=0A= if ((ttystrname =3D ztrdup(ttyname(0)))) {=0A= - SHTTY =3D movefd(open(ttystrname, O_RDWR | O_NOCTTY));=0A= + SHTTY =3D movefd(block_open(ttystrname, O_RDWR | O_NOCTTY));=0A= #ifdef TIOCNXCL=0A= /*=0A= * See if the terminal claims to be busy. If so, and fd 0=0A= @@ -438,7 +438,7 @@ init_io(void)=0A= ttystrname =3D ztrdup(ttyname(1));=0A= }=0A= if (SHTTY =3D=3D -1 &&=0A= - (SHTTY =3D movefd(open("/dev/tty", O_RDWR | O_NOCTTY))) !=3D -1) {=0A= + (SHTTY =3D movefd(block_open("/dev/tty", O_RDWR | O_NOCTTY))) !=3D = -1) {=0A= zsfree(ttystrname);=0A= ttystrname =3D ztrdup(ttyname(SHTTY));=0A= }=0A= @@ -1235,3 +1235,33 @@ zsh_main(int argc, char **argv)=0A= : "use 'logout' to logout.", NULL, 0);=0A= }=0A= }=0A= +=0A= +/**/=0A= +int=0A= +block_open (const char *tty, int flags)=0A= +{=0A= + int saved_errno;=0A= + int fd;=0A= +=0A= + if ((flags & O_NONBLOCK) =3D=3D 0) {=0A= + fd =3D open (tty, flags | O_NONBLOCK);=0A= + if (fd =3D=3D -1)=0A= + return fd;=0A= + flags =3D fcntl(fd, F_GETFL);=0A= + if (flags =3D=3D -1)=0A= + goto bad;=0A= + flags &=3D ~O_NONBLOCK;=0A= + if (fcntl(fd, F_SETFL, flags) =3D=3D -1)=0A= + goto bad;=0A= + }=0A= + else=0A= + fd =3D open (tty, flags);=0A= +=0A= + return fd;=0A= +=0A= +bad:=0A= + saved_errno =3D errno;=0A= + close (fd);=0A= + errno =3D saved_errno;=0A= + return -1;=0A= +}=0A= ------_=_NextPart_000_01C2559A.A6047630--