about summary refs log tree commit diff
path: root/Src/Modules/zpty.c
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-03 19:01:58 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-03 19:01:58 +0000
commit4782ffd10519ee20ddb85335bda9b8dfe465e18f (patch)
tree8f7fe9325f5dc4e830b13fa865a478e8ecc002d5 /Src/Modules/zpty.c
parent26a29e1a3b9bc15269e6fd634f28edb537123512 (diff)
downloadzsh-4782ffd10519ee20ddb85335bda9b8dfe465e18f.tar.gz
zsh-4782ffd10519ee20ddb85335bda9b8dfe465e18f.tar.xz
zsh-4782ffd10519ee20ddb85335bda9b8dfe465e18f.zip
manual/9988
Diffstat (limited to 'Src/Modules/zpty.c')
-rw-r--r--Src/Modules/zpty.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 250b769a3..978fd18b5 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -158,7 +158,7 @@ get_pty(int *master, int *slave)
 
 #else /* ! __osf__ */
 
-#if __SVR4
+#if defined(__SVR4) || defined(sinix)
 
 #include <sys/stropts.h>
 
@@ -167,11 +167,12 @@ get_pty(int *master, int *slave)
 {
     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 @@ get_pty(int *master, int *slave)
 	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;
+	}
     *master = mfd;
     *slave = sfd;
 
     return 0;
 }
 
-#else /* ! __SVR4 */
+#else /* ! (defined(__SVR4) || defined(sinix))  */
 
 static int
 get_pty(int *master, int *slave)