Mercurial > cpython-lru_cache-weakref
changeset 87565:63c1fbc4de4b
Issue #19752: Fix "HAVE_DEV_PTMX" implementation of os.openpty()
Regression introduced by the implementation of the PEP 446 (non-inheritable
file descriptors by default).
master_fd must be set non-inheritable after the creation of the slave_fd,
otherwise grantpt(master_fd) fails with EPERM (errno 13).
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Mon, 25 Nov 2013 23:19:58 +0100 |
| parents | 2a1de922651a |
| children | 3ac8f9d5c2d8 |
| files | Modules/posixmodule.c |
| diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/posixmodule.c Mon Nov 25 13:25:12 2013 -0800 +++ b/Modules/posixmodule.c Mon Nov 25 23:19:58 2013 +0100 @@ -6014,7 +6014,7 @@ goto posix_error; #else - master_fd = _Py_open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */ + master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */ if (master_fd < 0) goto posix_error; @@ -6041,6 +6041,10 @@ slave_fd = _Py_open(slave_name, O_RDWR | O_NOCTTY); /* open slave */ if (slave_fd < 0) goto posix_error; + + if (_Py_set_inheritable(master_fd, 0, NULL) < 0) + goto posix_error; + #if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC) ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */ ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
