Don't want child process inheriting open sockets

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Tue Jan 22 21:50:57 EST 2008


En Tue, 22 Jan 2008 13:02:35 -0200, Steven Watanabe  
<Steven.Watanabe at autodesk.com> escribió:

> I'm using subprocess.Popen() to create a child process. The child  
> process is inheriting the parent process' open sockets, but I don't want  
> that. I believe that on Unix systems I could use the FD_CLOEXEC flag,  
> but I'm running Windows. Any suggestions?

You could use the DuplicateHandle Windows API function with  
bInheritHandle=False to create a non inheritable socket handle, then close  
the original one. This should be done for every socket you don't want to  
be inherited.

-- 
Gabriel Genellina




More information about the Python-list mailing list