[Python-checkins] cpython: Issue #19752: Fix "HAVE_DEV_PTMX" implementation of os.openpty()
victor.stinner
python-checkins at python.org
Mon Nov 25 23:20:16 CET 2013
http://hg.python.org/cpython/rev/63c1fbc4de4b
changeset: 87565:63c1fbc4de4b
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Nov 25 23:19:58 2013 +0100
summary:
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).
files:
Modules/posixmodule.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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 */
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list