From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4341 invoked from network); 3 Mar 2000 16:33:33 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 3 Mar 2000 16:33:33 -0000 Received: (qmail 22324 invoked by alias); 3 Mar 2000 16:33:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9981 Received: (qmail 22317 invoked from network); 3 Mar 2000 16:33:28 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "ZSH workers mailing list" Subject: PATCH: 3.1.6-dev-19 + patches: zpty.c SINIX/autopush Date: Fri, 3 Mar 2000 19:33:25 +0300 Message-ID: <000701bf852e$32a076b0$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 - add #if defined(sinix). Dunno, where __SVR4 comes from. Probably, __svr4__ should be there as well (I believe, GCC is using it). But really, we should test for features not for OSes ... - modules can be autopushed when tty is opened. It is probably wrong to push it the second time. The code is paranoid in that it tests for I_FIND failure (I cannot imagine when it can fail in this case). It also reorders grantpt()/ptsname() - at least in my docs it is shown this way. Just in case. regards /andrej --- Src/Modules/zpty.c.org Fri Mar 3 11:50:37 2000 +++ Src/Modules/zpty.c Fri Mar 3 18:33:24 2000 @@ -158,7 +158,7 @@ #else /* ! __osf__ */ -#if __SVR4 +#if defined(__SVR4) || defined(sinix) #include @@ -167,11 +167,12 @@ { int mfd, sfd; char *name; + int ret; if ((mfd = open("/dev/ptmx", O_RDWR)) < 0) return 1; - if (!(name = ptsname(mfd)) || grantpt(mfd) || unlockpt(mfd)) { + if (grantpt(mfd) || unlockpt(mfd) || !(name = ptsname(mfd))) { close(mfd); return 1; } @@ -179,20 +180,31 @@ close(mfd); return 1; } - if (ioctl(sfd, I_PUSH, "ptem") || - ioctl(sfd, I_PUSH, "ldterm") || - ioctl(sfd, I_PUSH, "ttcompat")) { - close(mfd); - close(sfd); - return 1; - } + if ((ret = ioctl(sfd, I_FIND, "ptem")) != 1) + if (ret == -1 || ioctl(sfd, I_PUSH, "ptem") == -1) { + close(mfd); + close(sfd); + return 1; + } + if ((ret = ioctl(sfd, I_FIND, "ldterm")) != 1) + if (ret == -1 || ioctl(sfd, I_PUSH, "ldterm") == -1) { + close(mfd); + close(sfd); + return 1; + } + if ((ret = ioctl(sfd, I_FIND, "ttcompat")) != 1) + if (ret == -1 || ioctl(sfd, I_PUSH, "ttcompat") == -1) { + close(mfd); + close(sfd); + return 1; + } bor@itsrm2% gdiff -u Src/Modules/zpty.c{.org,} > ~/tmp/zpty.diff bor@itsrm2%