Mercurial > vim
comparison src/os_unix.c @ 11925:fe6675d67a10 v8.0.0842
patch 8.0.0842: using slave pty after closing it
commit https://github.com/vim/vim/commit/223896d3e9d4d511fc38fd9ee27ba16318733df6
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 2 22:33:28 2017 +0200
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 02 Aug 2017 22:45:04 +0200 |
parents | cca097489de5 |
children | d033653d3df8 |
comparison
equal
deleted
inserted
replaced
11924:6d2c06fb42dd | 11925:fe6675d67a10 |
---|---|
5314 set_default_child_environment(); | 5314 set_default_child_environment(); |
5315 | 5315 |
5316 if (use_null_for_in || use_null_for_out || use_null_for_err) | 5316 if (use_null_for_in || use_null_for_out || use_null_for_err) |
5317 null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0); | 5317 null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0); |
5318 | 5318 |
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 | |
5319 /* set up stdin for the child */ | 5330 /* set up stdin for the child */ |
5320 close(0); | 5331 close(0); |
5321 if (use_null_for_in && null_fd >= 0) | 5332 if (use_null_for_in && null_fd >= 0) |
5322 ignored = dup(null_fd); | 5333 ignored = dup(null_fd); |
5323 else if (fd_in[0] < 0) | 5334 else if (fd_in[0] < 0) |
5360 close(fd_err[0]); | 5371 close(fd_err[0]); |
5361 if (fd_err[1] >= 0) | 5372 if (fd_err[1] >= 0) |
5362 close(fd_err[1]); | 5373 close(fd_err[1]); |
5363 if (pty_master_fd >= 0) | 5374 if (pty_master_fd >= 0) |
5364 { | 5375 { |
5365 close(pty_master_fd); /* not used */ | 5376 close(pty_master_fd); /* not used in the child */ |
5366 close(pty_slave_fd); /* duped above */ | 5377 close(pty_slave_fd); /* was duped above */ |
5367 } | 5378 } |
5368 | 5379 |
5369 if (null_fd >= 0) | 5380 if (null_fd >= 0) |
5370 close(null_fd); | 5381 close(null_fd); |
5371 | |
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 | 5382 |
5383 /* See above for type of argv. */ | 5383 /* See above for type of argv. */ |
5384 execvp(argv[0], argv); | 5384 execvp(argv[0], argv); |
5385 | 5385 |
5386 if (stderr_works) | 5386 if (stderr_works) |