diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-28 14:59:59 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-28 14:59:59 +0200 |
commit | 1e44968780bb6ddb48bf22dc629a579c4035d5b3 (patch) | |
tree | af7b16ca55d8bf2dac6e38d14661d9e2f0ad33f6 /src/pty.c | |
parent | f720d0a77e393990b2171a77210565bdc82064f2 (diff) | |
download | vim-git-1e44968780bb6ddb48bf22dc629a579c4035d5b3.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)
Diffstat (limited to 'src/pty.c')
-rw-r--r-- | src/pty.c | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -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]; |