[New-bugs-announce] [issue4708] os.pipe should return inheritable descriptors (Windows)

Aaron Brady report at bugs.python.org
Sun Dec 21 03:15:25 CET 2008

New submission from Aaron Brady <castironpi at gmail.com>:

os.pipe should return inheritable descriptors on Windows.

Patch below, test attached.  New pipe() returns descriptors, which
cannot be inherited.  However, their permissions are set correctly, so
msvcrt.get_osfhandle and msvcrt.open_osfhandle can be used to obtain an
inheritable handle.

Docs should contain a note to the effect.  'On Windows, use
msvcrt.get_osfhandle to obtain a handle to the descriptor which can be
inherited.  In a subprocess, use msvcrt.open_osfhandle to obtain a new
corresponding descriptor.'

--- posixmodule_orig.c  2008-12-20 20:01:38.296875000 -0600
+++ posixmodule_new.c   2008-12-20 20:01:54.359375000 -0600
@@ -6481,8 +6481,12 @@
        HANDLE read, write;
        int read_fd, write_fd;
        BOOL ok;
-       ok = CreatePipe(&read, &write, NULL, 0);
+       sAttribs.nLength = sizeof( sAttribs );
+       sAttribs.lpSecurityDescriptor = NULL;
+       sAttribs.bInheritHandle = TRUE;
+       ok = CreatePipe(&read, &write, &sAttribs, 0);
        if (!ok)
                return win32_error("CreatePipe", NULL);

components: Library (Lib), Windows
files: os_pipe_test.py
messages: 78136
nosy: castironpi
severity: normal
status: open
title: os.pipe should return inheritable descriptors (Windows)
type: behavior
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file12408/os_pipe_test.py

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list