sftp breakage on Win32

David Allouche david at allouche.net
Thu Dec 1 16:09:48 GMT 2005


On Wed, 2005-11-30 at 12:12 -0500, Matt Lavin wrote:
> After catching up with bzr.dev on my Windows machine I ran into the 
> following problem using sftp on Windows.  To work around the issue I 
> just removed the 'close_fds' argument, but I doubt that it the best 
> solution.  I checked the Python docs and it doesn't mention that the 
> argument is not supported on Windows.

From memory, when I looked quite closely at how subprocess handled
process spawning and compared it to twisted, and asked Robert Collins
for extra information:

      * On win32, fds are not inherited, you have to pass them
        explicitly across to the subprocess. So close_fds is implicit on
        win32.
      * That's probably one reason why twisted will close all fds not
        explicitely passed to the subprocess, which makes process
        spawning in twisted quite needlessly expensive (it iterate over
        all 32k entries of the fd space).
      * The subprocess module does not provide support for passing
        anything but stdio fds. Except when using the  preexec callback
        which is not supported on windows either because subprocesses
        there are created by spawn, not by fork-exec.

In my opinion, the subprocess module sucks seriously in that particular
respect, but it's still clearly the least broken process spawning
facility available in the standard library.

So, if my understanding of the situation is correct, and you care about
close_fds, you need to duplicate the os.name check done in the
subprocess module and pass close_fds set close_fds to true if and only
if that test says it's not windows.

However, you probably do not need to care about close_fds because, as
far as I know, the number of open fds on a file only makes a difference
for pipes (i/o on a pipe may block instead of failing if some subprocess
has a stray fd to this pipe).

Caveats, that's all from memory, and I do not really know anything about
windows process and fd handling.
-- 
                                                            -- ddaa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051201/3d84a348/attachment.pgp 


More information about the bazaar mailing list