summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-28 14:59:59 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-28 14:59:59 +0200
commit1e44968780bb6ddb48bf22dc629a579c4035d5b3 (patch)
treeaf7b16ca55d8bf2dac6e38d14661d9e2f0ad33f6
parentf720d0a77e393990b2171a77210565bdc82064f2 (diff)
downloadvim-git-8.1.1225.tar.gz
patch 8.1.1225: cannot create a pty to use with :terminal on FreeBSDv8.1.1225
Problem: Cannot create a pty to use with :terminal on FreeBSD. Solution: Add support for posix_openpt(). (Ozaki Kiichi, closes #4306, closes #4289)
-rwxr-xr-xsrc/auto/configure2
-rw-r--r--src/config.h.in1
-rw-r--r--src/configure.ac2
-rw-r--r--src/pty.c39
-rw-r--r--src/version.c2
5 files changed, 41 insertions, 5 deletions
diff --git a/src/auto/configure b/src/auto/configure
index c27385791..19982730d 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -12658,7 +12658,7 @@ for ac_func in fchdir fchown fchmod fsync getcwd getpseudotty \
getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
- usleep utime utimes mblen ftruncate unsetenv
+ usleep utime utimes mblen ftruncate unsetenv posix_openpt
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/src/config.h.in b/src/config.h.in
index 7fe65de57..3f122fddb 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -180,6 +180,7 @@
#undef HAVE_NANOSLEEP
#undef HAVE_NL_LANGINFO_CODESET
#undef HAVE_OPENDIR
+#undef HAVE_POSIX_OPENPT
#undef HAVE_PUTENV
#undef HAVE_QSORT
#undef HAVE_READLINK
diff --git a/src/configure.ac b/src/configure.ac
index be869d1d5..2a3bc33b4 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -3746,7 +3746,7 @@ AC_CHECK_FUNCS(fchdir fchown fchmod fsync getcwd getpseudotty \
getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \
sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \
strnicmp strpbrk strtol tgetent towlower towupper iswupper \
- usleep utime utimes mblen ftruncate unsetenv)
+ usleep utime utimes mblen ftruncate unsetenv posix_openpt)
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_FSEEKO
diff --git a/src/pty.c b/src/pty.c
index 23ea0c06c..ece360f37 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -136,6 +136,13 @@
# define O_NOCTTY 0
#endif
+#if defined(HAVE_SVR4_PTYS) || defined(HAVE_POSIX_OPENPT)
+// These should be in stdlib.h, but it depends on _XOPEN_SOURCE.
+char *ptsname(int);
+int unlockpt(int);
+int grantpt(int);
+#endif
+
static void
initmaster(int f UNUSED)
{
@@ -178,6 +185,35 @@ setup_slavepty(int fd)
return 0;
}
+#if defined(HAVE_POSIX_OPENPT) && !defined(PTY_DONE)
+#define PTY_DONE
+ int
+mch_openpty(char **ttyn)
+{
+ int f;
+ char *m;
+ RETSIGTYPE (*sigcld) SIGPROTOARG;
+ static char TtyName[32]; // used for opening a new pty-pair
+
+ if ((f = posix_openpt(O_RDWR | O_NOCTTY | O_EXTRA)) == -1)
+ return -1;
+
+ // SIGCHLD set to SIG_DFL for grantpt() because it fork()s and
+ // exec()s pt_chmod
+ sigcld = signal(SIGCHLD, SIG_DFL);
+ if ((m = ptsname(f)) == NULL || grantpt(f) || unlockpt(f))
+ {
+ signal(SIGCHLD, sigcld);
+ close(f);
+ return -1;
+ }
+ signal(SIGCHLD, sigcld);
+ vim_strncpy((char_u *)TtyName, (char_u *)m, sizeof(TtyName) - 1);
+ initmaster(f);
+ *ttyn = TtyName;
+ return f;
+}
+#endif
#if defined(OSX) && !defined(PTY_DONE)
#define PTY_DONE
@@ -280,9 +316,6 @@ mch_openpty(char **ttyn)
{
int f;
char *m;
- char *(ptsname(int));
- int unlockpt(int);
- int grantpt(int);
RETSIGTYPE (*sigcld) SIGPROTOARG;
/* used for opening a new pty-pair: */
static char TtyName[32];
diff --git a/src/version.c b/src/version.c
index ae93dc3a4..7c42d182e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1225,
+/**/
1224,
/**/
1223,