diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-08-02 22:33:28 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-08-02 22:33:28 +0200 |
commit | 223896d3e9d4d511fc38fd9ee27ba16318733df6 (patch) | |
tree | 7c78cee64e797f8f6d7874a76918c9fb6aa8f465 | |
parent | 5c838a3e7141f9950508c84439d2f959bc67e941 (diff) | |
download | vim-git-223896d3e9d4d511fc38fd9ee27ba16318733df6.tar.gz |
patch 8.0.0842: using slave pty after closing itv8.0.0842
Problem: Using slave pty after closing it.
Solution: Do the ioctl() before dup'ing it.
-rw-r--r-- | src/os_unix.c | 26 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index fb2628c7e..7c4b3180e 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5316,6 +5316,17 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options) if (use_null_for_in || use_null_for_out || use_null_for_err) null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0); + if (pty_slave_fd >= 0) + { + /* push stream discipline modules */ + SetupSlavePTY(pty_slave_fd); +# ifdef TIOCSCTTY + /* Try to become controlling tty (probably doesn't work, + * unless run by root) */ + ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL); +# endif + } + /* set up stdin for the child */ close(0); if (use_null_for_in && null_fd >= 0) @@ -5362,24 +5373,13 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options) close(fd_err[1]); if (pty_master_fd >= 0) { - close(pty_master_fd); /* not used */ - close(pty_slave_fd); /* duped above */ + close(pty_master_fd); /* not used in the child */ + close(pty_slave_fd); /* was duped above */ } if (null_fd >= 0) close(null_fd); - if (pty_slave_fd >= 0) - { - /* push stream discipline modules */ - SetupSlavePTY(pty_slave_fd); -# ifdef TIOCSCTTY - /* Try to become controlling tty (probably doesn't work, - * unless run by root) */ - ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL); -# endif - } - /* See above for type of argv. */ execvp(argv[0], argv); diff --git a/src/version.c b/src/version.c index 19ad732cb..0ef1f452b 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 842, +/**/ 841, /**/ 840, |