Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-08-22 Thread Gabriel Genellina
On 21 ago, 21:30, Seun Osewa <[EMAIL PROTECTED]> wrote: > Is it possible to cause this sort of thing to happen on Windows. > Specifically, I'm looking for a way to cause multiple processes to > accept new connections on a bound socket. on UNIX, I can just fork() > after binding the server socket

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-08-21 Thread Seun Osewa
Is it possible to cause this sort of thing to happen on Windows. Specifically, I'm looking for a way to cause multiple processes to accept new connections on a bound socket. on UNIX, I can just fork() after binding the server socket to a port and the children can accept() on that same socket, but

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Steve Holden
Hrvoje Niksic wrote: > alf <[EMAIL PROTECTED]> writes: > >> still would like to find out why it is happening (now FD_CLOEXEC >> narrowed may yahooing/googling searches). While realize that file >> descriptors are shared by forked processes it is still weird why the >> port moves to the child proce

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Hrvoje Niksic
alf <[EMAIL PROTECTED]> writes: > still would like to find out why it is happening (now FD_CLOEXEC > narrowed may yahooing/googling searches). While realize that file > descriptors are shared by forked processes it is still weird why the > port moves to the child process once parent gets killed. w

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Jeff McNeil
The open file descriptor/socket shouldn't "move" between processes when you kill the parent. When os.system forks, anything you've got open in the parent will transfer to the child. Both descriptors reference the same open port. Running the same 'ss' and 'cc' code you've supplied behaves like t

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Jean-Paul Calderone
On Fri, 20 Jul 2007 08:15:39 -0500, alf <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: > >> >> 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(), fcnt

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread alf
Jean-Paul Calderone wrote: > > 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) > thx for responding (I was about to

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Jean-Paul Calderone
On Thu, 19 Jul 2007 21:07:55 -0500, alf <[EMAIL PROTECTED]> 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

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-19 Thread Jeff McNeil
What's unexpected about it? Child processes inherit all of the open file descriptors of their parent. A socket is simply another open file descriptor. When your parent process exits, your child still holds a valid, open file descriptor. import sys import socket import os import time s = socket

subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-19 Thread alf
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: [myhost] ~> cat ss.py import socket UDPSock=