about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-03-16 19:52:52 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-03-16 19:52:52 +0000
commit89057ab5120cec36168e2bfb0fe36da59d1eb5bd (patch)
tree2d135a2fa9b2b43b635bffd9e4f0d85bdbaf0faf
parent851c3882edc21ce0df065321ef5903e89137710e (diff)
downloadzsh-89057ab5120cec36168e2bfb0fe36da59d1eb5bd.tar.gz
zsh-89057ab5120cec36168e2bfb0fe36da59d1eb5bd.tar.xz
zsh-89057ab5120cec36168e2bfb0fe36da59d1eb5bd.zip
19629: fix zpty on HP-UX
-rw-r--r--ChangeLog5
-rw-r--r--Src/Modules/zpty.c29
2 files changed, 28 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 32c92839c..d3b2f66a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-03-16  Peter Stephenson  <pws@csr.com>
+
+	* 19629: Src/Modules/zpty.c: implement Oliver's research into
+	making zpty work under HP-UX.
+
 2004-03-16  Clint Adams  <clint@zsh.org>
 
 	* 19640: Src/Modules/pcre.c: improve error reporting a bit.
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 08ec1b2bd..360d1cc63 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -160,12 +160,31 @@ getptycmd(char *name)
 #include <sys/stropts.h>
 #endif
 
+#if defined(I_FIND) && defined(I_PUSH)
+/*
+ * These tests are ad hoc.  Unfortunately if you get the wrong ioctl,
+ * STREAMS simply hangs up, so there's no obvious way of doing this
+ * more systematically.
+ *
+ * Apparently Solaris needs all three ioctls, but HP-UX doesn't need
+ * ttcompat.  The Solaris definition has been extended to all __SVR4
+ * as a guess; I have no idea if this is right.
+ */
+#ifdef __SVR4
+#define USE_STREAMS_IOCTLS
+#define USE_STREAMS_TTCOMPAT
+#endif
+#ifdef __hpux
+#define USE_STREAMS_IOCTLS
+#endif
+#endif
+
 static int
 get_pty(int master, int *retfd)
 {
     static char *name;
     static int mfd, sfd;
-#if defined(I_FIND) && defined(I_PUSH) && defined(__SVR4)
+#ifdef USE_STREAMS_IOCTLS
     int ret;
 #endif
 
@@ -190,11 +209,7 @@ get_pty(int master, int *retfd)
 	close(mfd);
 	return 1;
     }
-#if defined(I_FIND) && defined(I_PUSH) && defined(__SVR4)
-    /*
-     * Use if STREAMS is available.  The test is probably OK,
-     * but we could use e.g. the sys/stropts.h test.
-     */
+#ifdef USE_STREAMS_IOCTLS
     if ((ret = ioctl(sfd, I_FIND, "ptem")) != 1)
        if (ret == -1 || ioctl(sfd, I_PUSH, "ptem") == -1) {
 	   close(mfd);
@@ -207,6 +222,7 @@ get_pty(int master, int *retfd)
 	   close(sfd);
 	   return 1;
        }
+#ifdef USE_STREAMS_TTCOMPAT
     if ((ret = ioctl(sfd, I_FIND, "ttcompat")) != 1)
        if (ret == -1 || ioctl(sfd, I_PUSH, "ttcompat") == -1) {
 	   close(mfd);
@@ -214,6 +230,7 @@ get_pty(int master, int *retfd)
 	   return 1;
        }
 #endif
+#endif
 
     *retfd = sfd;