diff options
| author | ZyX <kp-pav@yandex.ru> | 2017-11-26 15:54:03 +0300 | 
|---|---|---|
| committer | ZyX <kp-pav@yandex.ru> | 2017-11-26 15:54:03 +0300 | 
| commit | b9c78130587e42ca3b6417b47fb739a166da8eb7 (patch) | |
| tree | 142cf7dd0a87dfb32a20838e7683dd1980e4b3e7 /src/nvim/os/pty_process_unix.c | |
| parent | 05a3c12118a6dae0ac8f3603f9ee4d9fd9450cce (diff) | |
| parent | 207b7ca4bc16d52641eaa5244eef25a0dba91dbc (diff) | |
| download | rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.tar.gz rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.tar.bz2 rneovim-b9c78130587e42ca3b6417b47fb739a166da8eb7.zip  | |
Merge branch 'master' into expression-parser
Diffstat (limited to 'src/nvim/os/pty_process_unix.c')
| -rw-r--r-- | src/nvim/os/pty_process_unix.c | 31 | 
1 files changed, 22 insertions, 9 deletions
diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index ee3ab96a83..53301e4b53 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -36,23 +36,36 @@  # include "os/pty_process_unix.c.generated.h"  #endif +/// termios saved at startup (for TUI) or initialized by pty_process_spawn(). +static struct termios termios_default; + +/// Saves the termios properties associated with `tty_fd`. +/// +/// @param tty_fd   TTY file descriptor, or -1 if not in a terminal. +void pty_process_save_termios(int tty_fd) +{ +  if (tty_fd == -1 || tcgetattr(tty_fd, &termios_default) != 0) { +    return; +  } +} +  /// @returns zero on success, or negative error code  int pty_process_spawn(PtyProcess *ptyproc)    FUNC_ATTR_NONNULL_ALL  { -  static struct termios termios; -  if (!termios.c_cflag) { -    init_termios(&termios); +  if (!termios_default.c_cflag) { +    // TODO(jkeyes): We could pass NULL to forkpty() instead ... +    init_termios(&termios_default);    }    int status = 0;  // zero or negative error code (libuv convention)    Process *proc = (Process *)ptyproc; -  assert(!proc->err); +  assert(proc->err.closed);    uv_signal_start(&proc->loop->children_watcher, chld_handler, SIGCHLD);    ptyproc->winsize = (struct winsize){ ptyproc->height, ptyproc->width, 0, 0 };    uv_disable_stdio_inheritance();    int master; -  int pid = forkpty(&master, NULL, &termios, &ptyproc->winsize); +  int pid = forkpty(&master, NULL, &termios_default, &ptyproc->winsize);    if (pid < 0) {      status = -errno; @@ -83,12 +96,12 @@ int pty_process_spawn(PtyProcess *ptyproc)      goto error;    } -  if (proc->in -      && (status = set_duplicating_descriptor(master, &proc->in->uv.pipe))) { +  if (!proc->in.closed +      && (status = set_duplicating_descriptor(master, &proc->in.uv.pipe))) {      goto error;    } -  if (proc->out -      && (status = set_duplicating_descriptor(master, &proc->out->uv.pipe))) { +  if (!proc->out.closed +      && (status = set_duplicating_descriptor(master, &proc->out.uv.pipe))) {      goto error;    }  | 
