File: openpty.dpatch

package info (click to toggle)
xvt 2.1-14
  • links: PTS
  • area: main
  • in suites: woody
  • size: 348 kB
  • ctags: 430
  • sloc: ansic: 5,107; perl: 1,329; makefile: 31; sh: 29
file content (44 lines) | stat: -rw-r--r-- 1,237 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#PATCHOPTIONS: -p1 -F3

diff -ur debian/xvt-2.1/ttyinit.c ./ttyinit.c
--- debian/xvt-2.1/ttyinit.c	Sat Jul 10 13:28:04 1999
+++ ./ttyinit.c	Sat Jul 10 13:17:24 1999
@@ -74,7 +74,9 @@
  * and then use a sequence of system calls to request and initialise the
  * pty pair.  Either of the two approaches are selected by defining one of
  * BSD_PTY and SVR4_PTY, but the only system I have found which supports
- * SVR4_PTY is SunOS 5.
+ * SVR4_PTY is SunOS 5.  Some systems have a function called openpty()
+ * which "does the right thing" for that system.  Defining LIBC_OPENPTY
+ * selects this approach.  This is the case for glibc2-based systems.
  * 
  * Creation of a controlling teletype
  * ----------------------------------
@@ -155,7 +157,7 @@
 
 #ifdef LINUX
 #include <sys/ioctl.h>
-#define BSD_PTY
+#define LIBC_OPENPTY
 #define SVR4_UTMP
 #endif
 
@@ -466,6 +468,18 @@
 	ioctl(sfd,I_PUSH,"ptem");
 	ioctl(sfd,I_PUSH,"ldterm");
 #endif /* SVR4_PTY */
+
+#ifdef LIBC_OPENPTY
+	char *ttynam;
+	int mfd, sfd;
+
+	if (openpty(&mfd, &sfd, NULL, NULL, NULL)) {
+		error("Cannot allocate a pseudo teletype");
+		perror("");
+		return(NULL);
+	}
+	ttynam = ttyname(sfd);
+#endif /* LIBC_OPENPTY */
 
 	*pslave = sfd;
 	*pmaster = mfd;