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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
--- GNUmakefile
+++ GNUmakefile
@@ -44,7 +44,10 @@
\
Label.m
-Terminal_LDFLAGS = -lutil
+ifeq ($(findstring gnu, $(GNUSTEP_TARGET_OS)), gnu)
+ # for forkpty on Linux
+ Terminal_LDFLAGS = -lutil
+endif
Terminal_LOCALIZED_RESOURCE_FILES = Localizable.strings
Terminal_LANGUAGES = English Swedish German French Spanish Hungarian Turkish \
--- TerminalView.m
+++ TerminalView.m
@@ -38,9 +38,11 @@
#include <fcntl.h>
#ifndef freebsd
#ifndef __NetBSD__
+#if !defined(solaris2)
# include <pty.h>
#endif
#endif
+#endif
#include <Foundation/NSBundle.h>
#include <Foundation/NSDebug.h>
@@ -1692,6 +1692,91 @@
master_fd=-1;
}
+#if defined(solaris2)
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/stream.h>
+#include <sys/stropts.h>
+#include <sys/syscall.h>
+#include <stdio.h>
+#include <errno.h>
+
+#define forkpty my_forkpty
+
+/**
+ * fork_pty() remplacement for Solaris, it ignores the last two
+ * arguments for the moment.
+ * http://bugs.mysql.com/bug.php?id=22429
+ */
+static int my_forkpty (int *amaster,
+ char *name,
+ void *unused1,
+ void *unused2)
+{
+ int master, slave;
+ char *slave_name;
+ pid_t pid;
+
+ master = open("/dev/ptmx", O_RDWR);
+ if (master < 0)
+ return -1;
+
+ if (grantpt(master) < 0) {
+ close (master);
+ return -1;
+ }
+
+ if (unlockpt(master) < 0) {
+ close (master);
+ return -1;
+ }
+
+ slave_name = ptsname(master);
+ if (slave_name == NULL) {
+ close (master);
+ return -1;
+ }
+
+ slave = open(slave_name, O_RDWR);
+ if (slave < 0) {
+ close (master);
+ return -1;
+ }
+
+ if (ioctl(slave, I_PUSH, "ptem") < 0 ||
+ ioctl(slave, I_PUSH, "ldterm") < 0)
+ {
+ close (slave);
+ close (master);
+ return -1;
+ }
+
+ if (amaster)
+ *amaster = master;
+
+ if (name)
+ strcpy (name, slave_name);
+
+ pid = fork();
+ switch (pid) {
+ case -1: /* Error */
+ return -1;
+ case 0: /* Child */
+ close(master);
+ dup2(slave, STDIN_FILENO);
+ dup2(slave, STDOUT_FILENO);
+ dup2(slave, STDERR_FILENO);
+ return 0;
+ default: /* Parent */
+ close (slave);
+ return pid;
+ }
+
+ return -1;
+}
+#endif
-(void) runProgram: (NSString *)path
withArguments: (NSArray *)args
|