zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.6-dev-19 + patches: zpty.c SINIX/autopush
@ 2000-03-03 16:33 Andrej Borsenkow
  0 siblings, 0 replies; only message in thread
From: Andrej Borsenkow @ 2000-03-03 16:33 UTC (permalink / raw)
  To: ZSH workers mailing list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-03-03 16:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-03 16:33 PATCH: 3.1.6-dev-19 + patches: zpty.c SINIX/autopush Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).