annotate src/pty.c @ 15089:e428882d6ffb v8.1.0555

patch 8.1.0555: crash when last search pat is set but not last substitute pat commit https://github.com/vim/vim/commit/2fb8f684d888ad68b283ba8f9505106b5fb725be Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 1 13:14:45 2018 +0100 patch 8.1.0555: crash when last search pat is set but not last substitute pat Problem: Crash when last search pat is set but not last substitute pat. Solution: Do not mix up last search pattern and last subtitute pattern. (closes #3647)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Dec 2018 13:15:04 +0100
parents 27b9a84395b5
children d4a6d575e910
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 * The stuff in this file mostly comes from the "screen" program.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Included with permission from Juergen Weigert.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * Copied from "pty.c". "putenv.c" was used for putenv() in misc2.c.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * It has been modified to work better with Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * The parts that are not used in Vim have been deleted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * See the "screen" sources for the complete stuff.
3282
7b59c2c032ca updated for version 7.3.409
Bram Moolenaar <bram@vim.org>
parents: 2834
diff changeset
17 *
7b59c2c032ca updated for version 7.3.409
Bram Moolenaar <bram@vim.org>
parents: 2834
diff changeset
18 * This specific version is distibuted under the Vim license (attribution by
7b59c2c032ca updated for version 7.3.409
Bram Moolenaar <bram@vim.org>
parents: 2834
diff changeset
19 * Juergen Weigert), the GPL applies to the original version, see the
7b59c2c032ca updated for version 7.3.409
Bram Moolenaar <bram@vim.org>
parents: 2834
diff changeset
20 * copyright notice below.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 /* Copyright (c) 1993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 * Copyright (c) 1987 Oliver Laumann
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 * This program is free software; you can redistribute it and/or modify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 * it under the terms of the GNU General Public License as published by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 * the Free Software Foundation; either version 2, or (at your option)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 * any later version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 * This program is distributed in the hope that it will be useful,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 * GNU General Public License for more details.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 * You should have received a copy of the GNU General Public License
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 * along with this program (see the file COPYING); if not, write to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 * Free Software Foundation, Inc.,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
11737
7791a15353dc patch 8.0.0751: OpenPTY missing with some combination of features
Christian Brabandt <cb@256bit.org>
parents: 11735
diff changeset
46 #if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL)
11735
21354977aa7b patch 8.0.0750: OpenPTY missing in non-GUI build
Christian Brabandt <cb@256bit.org>
parents: 10460
diff changeset
47
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #include <signal.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 #ifdef __CYGWIN32__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 # include <sys/termios.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 7
diff changeset
54 #ifdef HAVE_SYS_IOCTL_H
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 # include <sys/ioctl.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 #if HAVE_STROPTS_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 #include <sys/types.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 #ifdef sinix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 #define buf_T __system_buf_t__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 #include <stropts.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 #ifdef sinix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 #undef buf_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #endif
10460
7fd589f46801 commit https://github.com/vim/vim/commit/a899e6ecc4523c7e411eaf6fbaa4197d70f6f39e
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
67 # ifdef SUN_SYSTEM
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 # include <sys/conf.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 7
diff changeset
72 #ifdef HAVE_UNISTD_H
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 # include <unistd.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 #if HAVE_TERMIO_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 # include <termio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 #else
1030
d4bc24e6a281 updated for version 7.0-156
vimboss
parents: 7
diff changeset
79 # ifdef HAVE_TERMIOS_H
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 # include <termios.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 #if HAVE_SYS_STREAM_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 # include <sys/stream.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 #if HAVE_SYS_PTEM_H
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 # include <sys/ptem.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12576
diff changeset
92 #if !defined(SUN_SYSTEM) && !defined(VMS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 # include <sys/ioctl.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
10460
7fd589f46801 commit https://github.com/vim/vim/commit/a899e6ecc4523c7e411eaf6fbaa4197d70f6f39e
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
96 #if defined(SUN_SYSTEM) && defined(LOCKPTY) && !defined(TIOCEXCL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 # include <sys/ttold.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 #ifdef ISC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 # include <sys/tty.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 # include <sys/sioctl.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 # include <sys/pty.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 #ifdef sgi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # include <sys/sysmacros.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 #if defined(_INCLUDE_HPUX_SOURCE) && !defined(hpux)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 # define hpux
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 * if no PTYRANGE[01] is in the config file, we pick a default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #ifndef PTYRANGE0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 # define PTYRANGE0 "qprs"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 #ifndef PTYRANGE1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 # define PTYRANGE1 "0123456789abcdef"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 /* SVR4 pseudo ttys don't seem to work with SCO-5 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 #ifdef M_UNIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 # undef HAVE_SVR4_PTYS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 /*
2834
107b03fdf1ad updated for version 7.3.191
Bram Moolenaar <bram@vim.org>
parents: 2760
diff changeset
130 * Open all ptys with O_NOCTTY, just to be on the safe side.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 #ifndef O_NOCTTY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 # define O_NOCTTY 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 static void
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
137 initmaster(int f UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 #ifndef VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 # ifdef POSIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 tcflush(f, TCIOFLUSH);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 # ifdef TIOCFLUSH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 (void)ioctl(f, TIOCFLUSH, (char *) 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 # ifdef LOCKPTY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 (void)ioctl(f, TIOCEXCL, (char *) 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 * This causes a hang on some systems, but is required for a properly working
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 * pty on others. Needs to be tuned...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
158 SetupSlavePTY(int fd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 if (fd < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 #if defined(I_PUSH) && defined(HAVE_SVR4_PTYS) && !defined(sgi) && !defined(linux) && !defined(__osf__) && !defined(M_UNIX)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 # if defined(HAVE_SYS_PTEM_H) || defined(hpux)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 if (ioctl(fd, I_PUSH, "ptem") != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 if (ioctl(fd, I_PUSH, "ldterm") != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 return -1;
10460
7fd589f46801 commit https://github.com/vim/vim/commit/a899e6ecc4523c7e411eaf6fbaa4197d70f6f39e
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
169 # ifdef SUN_SYSTEM
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 if (ioctl(fd, I_PUSH, "ttcompat") != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 #if defined(OSX) && !defined(PTY_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 #define PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 int
7833
c079097365f3 commit https://github.com/vim/vim/commit/055409764ca5f7978d4c399d2c440af0ce971c4f
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
181 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 int f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 static char TtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 if ((f = open_controlling_pty(TtyName)) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 *ttyn = TtyName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 #if (defined(sequent) || defined(_SEQUENT_)) && defined(HAVE_GETPSEUDOTTY) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 && !defined(PTY_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 #define PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
198 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 char *m, *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 int f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 /* used for opening a new pty-pair: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 static char PtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 static char TtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 if ((f = getpseudotty(&s, &m)) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 #ifdef _SEQUENT_
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 fvhangup(s);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 #endif
2760
7fb8cdb9cb25 updated for version 7.3.156
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
211 vim_strncpy((char_u *)PtyName, (char_u *)m, sizeof(PtyName) - 1);
7fb8cdb9cb25 updated for version 7.3.156
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
212 vim_strncpy((char_u *)TtyName, (char_u *)s, sizeof(TtyName) - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 *ttyn = TtyName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 #if defined(__sgi) && !defined(PTY_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 #define PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
222 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 int f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 char *name;
7807
1a5d34492798 commit https://github.com/vim/vim/commit/d99df423c559d85c17779b3685426c489554908c
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
226 RETSIGTYPE (*sigcld) SIGPROTOARG;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 * SIGCHLD set to SIG_DFL for _getpty() because it may fork() and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 * exec() /usr/adm/mkpts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 sigcld = signal(SIGCHLD, SIG_DFL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 name = _getpty(&f, O_RDWR | O_NONBLOCK | O_EXTRA, 0600, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 signal(SIGCHLD, sigcld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 if (name == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 *ttyn = name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 #if defined(MIPS) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 #define PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
247 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 int f;
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
250 stat_T buf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 /* used for opening a new pty-pair: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 static char TtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 if ((f = open("/dev/ptc", O_RDWR | O_NOCTTY | O_NONBLOCK | O_EXTRA, 0)) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 if (mch_fstat(f, &buf) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 close(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 sprintf(TtyName, "/dev/ttyq%d", minor(buf.st_rdev));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 *ttyn = TtyName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
12576
b74f5036a434 patch 8.0.1166: :terminal doesn't work on Mac High Sierra
Christian Brabandt <cb@256bit.org>
parents: 11737
diff changeset
268 #if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE) && !defined(hpux) \
13353
8412df1479a3 patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
269 && !(defined(MACOS_X) && !defined(MAC_OS_X_VERSION_10_6))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
1703
ad8f5bdc7274 updated for version 7.2-001
vimboss
parents: 1624
diff changeset
271 /* NOTE: Even though HPUX can have /dev/ptmx, the code below doesn't work!
12576
b74f5036a434 patch 8.0.1166: :terminal doesn't work on Mac High Sierra
Christian Brabandt <cb@256bit.org>
parents: 11737
diff changeset
272 * Same for Mac OS X Leopard (10.5). */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 #define PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
275 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 int f;
2397
d5976fe4349d Fix for compiler warning about function prototype in pty.c.
Bram Moolenaar <bram@vim.org>
parents: 2154
diff changeset
278 char *m;
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 3282
diff changeset
279 char *(ptsname(int));
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 3282
diff changeset
280 int unlockpt(int);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 3282
diff changeset
281 int grantpt(int);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 3282
diff changeset
282 RETSIGTYPE (*sigcld) SIGPROTOARG;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 /* used for opening a new pty-pair: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 static char TtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 if ((f = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_EXTRA, 0)) == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 * SIGCHLD set to SIG_DFL for grantpt() because it fork()s and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 * exec()s pt_chmod
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 sigcld = signal(SIGCHLD, SIG_DFL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 if ((m = ptsname(f)) == NULL || grantpt(f) || unlockpt(f))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 signal(SIGCHLD, sigcld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 close(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 signal(SIGCHLD, sigcld);
2760
7fb8cdb9cb25 updated for version 7.3.156
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
301 vim_strncpy((char_u *)TtyName, (char_u *)m, sizeof(TtyName) - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 *ttyn = TtyName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 #if defined(_AIX) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 #define PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 #ifdef _IBMR2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 int aixhack = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
316 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 int f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 /* used for opening a new pty-pair: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 static char TtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 /* a dumb looking loop replaced by mycrofts code: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 if ((f = open("/dev/ptc", O_RDWR | O_NOCTTY | O_EXTRA)) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 return -1;
2760
7fb8cdb9cb25 updated for version 7.3.156
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
325 vim_strncpy((char_u *)TtyName, (char_u *)ttyname(f), sizeof(TtyName) - 1);
1076
17b9587ff6d5 updated for version 7.0-202
vimboss
parents: 1030
diff changeset
326 if (geteuid() != ROOT_UID && mch_access(TtyName, R_OK | W_OK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 close(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 # ifdef _IBMR2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 if (aixhack >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 close(aixhack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 if ((aixhack = open(TtyName, O_RDWR | O_NOCTTY | O_EXTRA, 0)) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 close(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 *ttyn = TtyName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 #ifndef PTY_DONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 # ifdef hpux
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 static char PtyProto[] = "/dev/ptym/ptyXY";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 static char TtyProto[] = "/dev/pty/ttyXY";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 # ifdef __BEOS__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 static char PtyProto[] = "/dev/pt/XY";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 static char TtyProto[] = "/dev/tt/XY";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 static char PtyProto[] = "/dev/ptyXY";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 static char TtyProto[] = "/dev/ttyXY";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7833
diff changeset
362 OpenPTY(char **ttyn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 char *p, *q, *l, *d;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 int f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 /* used for opening a new pty-pair: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 static char PtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 static char TtyName[32];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 strcpy(PtyName, PtyProto);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 strcpy(TtyName, TtyProto);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 for (p = PtyName; *p != 'X'; p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 for (q = TtyName; *q != 'X'; q++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 for (l = PTYRANGE0; (*p = *l) != '\0'; l++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 for (d = PTYRANGE1; (p[1] = *d) != '\0'; d++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 if ((f = open(PtyName, O_RDWR | O_NOCTTY | O_EXTRA, 0)) == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 q[0] = *l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 q[1] = *d;
1076
17b9587ff6d5 updated for version 7.0-202
vimboss
parents: 1030
diff changeset
384 if (geteuid() != ROOT_UID && mch_access(TtyName, R_OK | W_OK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 close(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 }
10460
7fd589f46801 commit https://github.com/vim/vim/commit/a899e6ecc4523c7e411eaf6fbaa4197d70f6f39e
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
389 #if defined(SUN_SYSTEM) && defined(TIOCGPGRP) && !defined(SUNOS3)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 /* Hack to ensure that the slave side of the pty is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 * unused. May not work in anything other than SunOS4.1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 int pgrp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 /* tcgetpgrp does not work (uses TIOCGETPGRP)! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 if (ioctl(f, TIOCGPGRP, (char *)&pgrp) != -1 || errno != EIO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 close(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 initmaster(f);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 *ttyn = TtyName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 return f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 #endif
11735
21354977aa7b patch 8.0.0750: OpenPTY missing in non-GUI build
Christian Brabandt <cb@256bit.org>
parents: 10460
diff changeset
412
21354977aa7b patch 8.0.0750: OpenPTY missing in non-GUI build
Christian Brabandt <cb@256bit.org>
parents: 10460
diff changeset
413 #endif /* FEAT_GUI || FEAT_TERMINAL */