The following patch against 21.1.7 adds support for Unix98 Ptys
(/dev/ptmx) as supported by Linux 2.2 kernels and glibc 2.1.
IMO the patch has one problem: It checks directly for __GLIBC__ and
only works for __GLIBC__. Replacing getpt with open ("/dev/ptmx",..)
and ptsname_r with ptsname would get this working on otherplatforms
(getpt and ptsname_r are glibc extensions - but getpt is quite useful
since it even works if /dev/ptmx doesn't work;-).
I guess, I should rewrite this and use some configure tests. Since
opening /dev/ptmx might involve some system specific handling, I would
check for now for grantpt, unlockpt and ptsname - and if all exists, define
USE_UNIX98_PTYS - and check additionally for getpt - and use
USE_UNIX98_PTYS && HAVE_GETPT instead of the check for glibc.
What do you think?
Andreas
--- process-unix.c
+++ process-unix.c Wed Dec 1 17:00:02 1999
@@ -204,6 +204,21 @@
static int
allocate_pty (void)
{
+ int fd;
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
+ if ((fd = getpt ()) < 0)
+ return -1;
+
+ if (grantpt (fd) < 0 ||
+ unlockpt (fd) < 0 ||
+ ptsname_r (fd, pty_name, sizeof pty_name))
+ {
+ close (fd);
+ return -1;
+ }
+ setup_pty (fd);
+ return fd;
+#else /* !glibc */
#ifndef PTY_OPEN
struct stat stb;
@@ -215,7 +230,6 @@
int failed_count = 0;
#endif
int i;
- int fd;
int c;
#ifdef PTY_ITERATION
@@ -283,6 +297,7 @@
}
}
return -1;
+#endif /* !glibc */
}
#endif /* HAVE_PTYS */
--
Andreas Jaeger
SuSE Labs aj(a)suse.de
private aj(a)arthur.rhein-neckar.de