Skip to content

Commit 223896d

Browse files
committed
patch 8.0.0842: using slave pty after closing it
Problem: Using slave pty after closing it. Solution: Do the ioctl() before dup'ing it.
1 parent 5c838a3 commit 223896d

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/os_unix.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5316,6 +5316,17 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
53165316
if (use_null_for_in || use_null_for_out || use_null_for_err)
53175317
null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0);
53185318

5319+
if (pty_slave_fd >= 0)
5320+
{
5321+
/* push stream discipline modules */
5322+
SetupSlavePTY(pty_slave_fd);
5323+
# ifdef TIOCSCTTY
5324+
/* Try to become controlling tty (probably doesn't work,
5325+
* unless run by root) */
5326+
ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
5327+
# endif
5328+
}
5329+
53195330
/* set up stdin for the child */
53205331
close(0);
53215332
if (use_null_for_in && null_fd >= 0)
@@ -5362,24 +5373,13 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
53625373
close(fd_err[1]);
53635374
if (pty_master_fd >= 0)
53645375
{
5365-
close(pty_master_fd); /* not used */
5366-
close(pty_slave_fd); /* duped above */
5376+
close(pty_master_fd); /* not used in the child */
5377+
close(pty_slave_fd); /* was duped above */
53675378
}
53685379

53695380
if (null_fd >= 0)
53705381
close(null_fd);
53715382

5372-
if (pty_slave_fd >= 0)
5373-
{
5374-
/* push stream discipline modules */
5375-
SetupSlavePTY(pty_slave_fd);
5376-
# ifdef TIOCSCTTY
5377-
/* Try to become controlling tty (probably doesn't work,
5378-
* unless run by root) */
5379-
ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL);
5380-
# endif
5381-
}
5382-
53835383
/* See above for type of argv. */
53845384
execvp(argv[0], argv);
53855385

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
842,
772774
/**/
773775
841,
774776
/**/

0 commit comments

Comments
 (0)