subprocess (spawned by os.system) inherits open TCP/UDP/IP port
steve at holdenweb.com
Fri Jul 20 20:38:34 CEST 2007
Hrvoje Niksic wrote:
> alf <ask at me> 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. what it the
>> parent got multiple subprocesses.
> Netstat probably shows only one of the processes that hold to the
> port, possibly the one with the lowest PID (the parent).
>> Plus it is kind of unintuitive os.system does not protect from such
>> behavoir which is for me more an equivalent of like issuing a ne
>> wcommand/ starting a process from the shell.
> It is considered a feature that fork/exec'ed programs inherit file
> descriptors -- that's how stdin and stdout get inherited all the time.
> It doesn't occur often with network connections because shells rarely
> have reason to open them.
It would be hard to figure out how (x)inetd or TCP wrappers could work
without the open connection being passed to the spawned server process.
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------
More information about the Python-list