mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
gh-77046: os.pipe() sets _O_NOINHERIT flag on fds (#113817)
On Windows, set _O_NOINHERIT flag on file descriptors created by os.pipe() and io.WindowsConsoleIO. Add test_pipe_spawnl() to test_os. Co-authored-by: Zackery Spytz <zspytz@gmail.com>
This commit is contained in:
parent
e82b096335
commit
1d75fa43a2
5 changed files with 68 additions and 6 deletions
|
|
@ -391,9 +391,9 @@ _io__WindowsConsoleIO___init___impl(winconsoleio *self, PyObject *nameobj,
|
|||
}
|
||||
|
||||
if (self->writable)
|
||||
self->fd = _Py_open_osfhandle_noraise(handle, _O_WRONLY | _O_BINARY);
|
||||
self->fd = _Py_open_osfhandle_noraise(handle, _O_WRONLY | _O_BINARY | _O_NOINHERIT);
|
||||
else
|
||||
self->fd = _Py_open_osfhandle_noraise(handle, _O_RDONLY | _O_BINARY);
|
||||
self->fd = _Py_open_osfhandle_noraise(handle, _O_RDONLY | _O_BINARY | _O_NOINHERIT);
|
||||
if (self->fd < 0) {
|
||||
PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, nameobj);
|
||||
CloseHandle(handle);
|
||||
|
|
|
|||
|
|
@ -11578,8 +11578,8 @@ os_pipe_impl(PyObject *module)
|
|||
Py_BEGIN_ALLOW_THREADS
|
||||
ok = CreatePipe(&read, &write, &attr, 0);
|
||||
if (ok) {
|
||||
fds[0] = _Py_open_osfhandle_noraise(read, _O_RDONLY);
|
||||
fds[1] = _Py_open_osfhandle_noraise(write, _O_WRONLY);
|
||||
fds[0] = _Py_open_osfhandle_noraise(read, _O_RDONLY | _O_NOINHERIT);
|
||||
fds[1] = _Py_open_osfhandle_noraise(write, _O_WRONLY | _O_NOINHERIT);
|
||||
if (fds[0] == -1 || fds[1] == -1) {
|
||||
CloseHandle(read);
|
||||
CloseHandle(write);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue