473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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



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=socket.socket(socket.AF_INET,socket.SOCK_D GRAM)
import os
os.system('python cc.py')

[myhost] ~cat cc.py
import time

then I start master one, do ctrl-Z and bg.

[myhost] ~python ss.py

[myhost] ~bg
[1] python ss.py &
[myhost] ~ps
myuser00 3192 3189 0 14:57 pts/0 00:00:00 -tcsh
myuser00 3247 3192 0 14:57 pts/0 00:00:00 python ss.py
myuser00 3248 3247 0 14:57 pts/0 00:00:00 python cc.py

[myhost] ~netstat -uanp |grep 12345
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
udp 0 0*

As expected netstat indicates process 3247 having port allocated. Then I
kill the master process and interestingly the child inherits the port open.
[myhost] ~kill 3247
[myhost] ~netstat -uanp | grep 12345
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
udp 0 0*
[1] + Terminated python ss.py

Why it is happening? I know that os.system uses fork, but still this is
something unexpected.
Thx, Alf

Jul 20 '07 #1
0 956

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Stewart Midwinter | last post by:
this has me puzzled; I've created a small test app to show the problem I'm having. I want to use subprocess to execute system commands from inside a Tkinter app running under Cygwin. When I...
by: George Sakkis | last post by:
I'm trying to figure out why Popen captures the stderr of a specific command when it runs through the shell but not without it. IOW: cmd = if 1: # this captures both stdout and stderr as...
by: Thomas Dybdahl Ahle | last post by:
Hi, When I do a small program like from subprocess import Popen popen = Popen() from time import sleep sleep(100) start it and kill it, the ping process lives on. Is there a way to ensure...
by: Eric_Dexter | last post by:
I am trying to modify a programming example and I am coming up with two problems... first is that I can't seem to pass along the arguments to the external command (I have been able to do that with...
by: Mrown | last post by:
Hi, I'm currently writing a python program that relies on a CLI program. What I'm currently doing is using subprocess.Popen on Python 2.5.1. Here's the line that I'm currently running: child...
by: | last post by:
Hello all I want to convert a tex file into a pdf by using pdflatex. For that, I thought the 'subprocess' module might be a good option. My code doesn't work atall tho: Import os, subprocess ...
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
by: Thomas Jansson | last post by:
Dear all I have tkinkter based frontend to a Fortran based program. I use subprocess to launch the fortran program as a child process and I wish to see the output of the fortran program as it is...
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.