subprocess (spawned by os.system) inherits open TCP/UDP/IP port
Jean-Paul Calderone
exarkun at divmod.com
Fri Jul 20 07:01:12 EDT 2007
On Thu, 19 Jul 2007 21:07:55 -0500, alf <ask at me.xs4all.nl> wrote:
>
>Hi,
>
>I need a help with explaining following behavior. Although it is not
>python issue per say, python helped me to write sample programs and
>originally I encountered the issue using python software. So let's
>assume we have two following programs:
>
> [snip - file descriptors inherited by child process]
You can avoid this, if you like. Set FD_CLOEXEC on the socket after you
open it, before you call os.system:
old = fcntl.fcntl(s.fileno(), fcntl.F_GETFD)
fcntl.fcntl(s.fileno(), fcntl.F_SETFD, old | fcntl.FD_CLOEXEC)
Jean-Paul
More information about the Python-list
mailing list