How to stop subprocesses from copying listening sockets
roy at panix.com
Fri Dec 26 04:05:43 CET 2008
In article <mailman.6204.1230258299.3487.python-list at python.org>,
Rick van Hattem <Rick at youtellme.com> wrote:
> Recently I've started building a program that spawns new processes when
> requested via http, since the http interface doesn't need to be fancy I've
> just used the BaseHTTPServer module for this, but... it seems I'm running
> into a little problem. When spawning a new process (which forks itself into a
> daemon, but isn't too relevant in this case) the listening socket is copied
> to the new process.
The standard solution to this problem is to close all descriptors after
forking and before doing the exec. You can tell subprocess.Popen() to do
this by call it with "close_fds=True".
More information about the Python-list