Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.1.6-dev-19 + patches: zpty.c SINIX/autopush



- 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 <sys/stropts.h>

@@ -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%



Messages sorted by: Reverse Date, Date, Thread, Author