On 24/07/2013 10:50pm, Victor Stinner wrote:
So would it be possible to implement the pass_fds parameter of
subprocess using spawnl() or the undocumented fields?
Not in a non-racy way.
spawnv() calls CreateProcess() with bInheritHandles=TRUE, so *all*
inheritable handles are inherited by the child.
The passing of the arrays of fds just makes the fds in the child process
match the fds in the parent.
If you have a Visual Studio installed then the relevant code is in
.../Microsoft Visual Studio 10.0/VC/crt/src/dospawn.c
And is it possible to close all handles except one (implement "pass_handles")?
I don't know how to do that.
In the experimental branch of multiprocessing, child processes
no longer inherit unnecessary handles.
Where is this branch? How did you create the channel between the
manager and the worker?
http://hg.python.org/sandbox/sbt/
The parent creates a pipe and starts the child process. The pid of the
parent, and the handle for the read end of the pipe are passed on the
command line. Then the child "steals" the handle from the parent using
OpenProcess() and DuplicateHandle() using the DUPLICATE_CLOSE_SOURCE flag.
--
Richard
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com