[Scons-dev] Question about .../SCons/Platform/win32.py

getspammed iwanttogetspammed at gmx.net
Wed Mar 19 12:02:54 EDT 2014


At the beginning of .../SCons/Platform/win32.py there are approx. 40 lines that
try to overide the builtin functions 'file' and 'open'. Those are replaced with
versions that make sure, that files created/opened with those functions have
underlying os file handles that are not inheritable.

The reasoning for this seems to be that inheritable file handles might interfere
with parallel builds (-j). I can not say anything about that.

But i am very sure that on windows file handles are created as non inheritable
by default. And i am sure that the msvcrt functions that python (CPython) uses
do not touch that default handling.

It is easy to check whether the file handle for a python file is inheritable
or not. Just use the same method that .../SCons/Platform/win32.py is using:


>>> import msvcrt

>>> import win32api

>>> f = open('inherit.txt', 'wt')

>>> win32api.GetHandleInformation(msvcrt.get_osfhandle(f.fileno()))

0

>>>


As you can see, the flag HANDLE_FLAG_INHERIT is not set, ie. the handle is not
inheritable.

So my questions are:
Why is that code there?
Does it handle situations (different OS or python interpreter) that i didn't
think of?

Regards,
Rocco


More information about the Scons-dev mailing list