-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
The Windows implementation of set_close_exec https://github.com/tornadoweb/tornado/blob/master/tornado/platform/windows.py currently can never work because SetHandleInformation needs an OS handle, but everywhere this function is called it is given a file descriptor.
Firstly, I believe that by default all handles are non-inheritable. But I haven't checked everywhere you're creating them though - certainly the returned pipes from os.pipe are explicitly noninheritable.
Most likely you should just use os.set_inheritable on all platforms, which does what you need. It was added in Python 3.4, so once 2.7 is no longer a concern this is probably the easiest way forward. It knows how to convert FDs to handles on Windows.
Finally, I came across this because I'm trying to bring up a Python environment on Windows that doesn't include ctypes, and this showed up on my list of "concerns". I'll patch my own to use the builtin function, but figured I'd mention that the current code doesn't work.