Author castironpi
Recipients castironpi
Date 2008-12-21.02:15:21
SpamBayes Score 7.30434e-06
Marked as misclassified No
Message-id <1229825725.05.0.791696937909.issue4708@psf.upfronthosting.co.za>
In-reply-to
Content
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;
+       SECURITY_ATTRIBUTES sAttribs;
        Py_BEGIN_ALLOW_THREADS
-       ok = CreatePipe(&read, &write, NULL, 0);
+       sAttribs.nLength = sizeof( sAttribs );
+       sAttribs.lpSecurityDescriptor = NULL;
+       sAttribs.bInheritHandle = TRUE;
+       ok = CreatePipe(&read, &write, &sAttribs, 0);
        Py_END_ALLOW_THREADS
        if (!ok)
                return win32_error("CreatePipe", NULL);
History
Date User Action Args
2008-12-21 02:15:25castironpisetrecipients: + castironpi
2008-12-21 02:15:25castironpisetmessageid: <1229825725.05.0.791696937909.issue4708@psf.upfronthosting.co.za>
2008-12-21 02:15:24castironpilinkissue4708 messages
2008-12-21 02:15:22castironpicreate