From 89057ab5120cec36168e2bfb0fe36da59d1eb5bd Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 16 Mar 2004 19:52:52 +0000 Subject: 19629: fix zpty on HP-UX --- Src/Modules/zpty.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'Src') 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 #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,12 +222,14 @@ 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); close(sfd); return 1; } +#endif #endif *retfd = sfd; -- cgit 1.4.1