[Twisted-Python] Windows spawnProcess - Child process inherits files and sockets (POSIX does not)

Glyph glyph at twistedmatrix.com
Thu Mar 31 15:27:08 MDT 2016


On Feb 21, 2016, at 7:14 PM, exvito here <ex.vitorino at gmail.com> wrote:
> 
> Hello all,
> 
> I filed https://twistedmatrix.com/trac/ticket/7970 <https://twistedmatrix.com/trac/ticket/7970> last summer while focused on a particular project that was hit by it. Since then I had to attend to other things and I'm now back to refocusing on that project.

Thanks for following up.  Sorry I've taken so long to respond; this is a highly complex issue that is tempting to just punt on thinking about.  But we really should address it, and thank you for writing a great bug report.

> Before submitting a patch for review, I'm looking for preliminary feedback, assuming you agree that the Windows vs POSIX semantics should be the same (if not, why?).

After much thought: Yes.  They should be the same.  The reason they're not is largely ignorance of the relevant APIs and abstractions on Windows, not any desire that they differ.  The one place they have to differ a little bit is handle inheritance: we need to figure out some way to express the 'childFDs' mapping in terms of both file descriptors and handles.

> My patch calls a few Windows APIs via ctypes, however, as far as I can tell, Twisted on Windows requires pywin32 and, recently, there has been some discussion around dropping that dependency and moving towards something based on cffi.

ctypes is dangerous and error-prone.  If you screw up the bit-width of a type, or the type in a header changes on some future version, ctypes gives you no way of finding out until some poor user's process segfaults, and usually not at the relevant call site.  So we'd prefer not to maintain more ctypes-using code.

The APIs in pywin32 very closely mirror the underlying Windows API, so for addressing this issue, please just go ahead and use pywin32 APIs; porting them to a new API along with everything else should be relatively straightforward.

If we do move forward with that change, we will probably use https://pypi.python.org/pypi/pywincffi and not move anything within Twisted.

> What would you say the way forward is? Should I submit the patch for review anyway? Is there any other work that needs to be done first that I may contribute to?

Yes, just go ahead and write the patch.

> Thanks in advance for Twisted and for your feedback,

Thanks for using Twisted, thanks doubly for trying to contribute, and very sorry for the slow response.

-glyph


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20160331/cf4a2c4e/attachment.html>


More information about the Twisted-Python mailing list