473,507 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.fork leaving processes behind

Hi all,

This may be more of a Linux question, but it relates to how Python
forks...

Today, I implemented a pretty simple listener script using os.fork.
The script runs fine, and performs as expected, but the process table
is left with an odd entry for every fork called.

I'm running on Slackware 9, under the 2.4 kernel, Python 2.5.1.

while True:
conn, addr = s.accept()
if os.fork():
continue
else:
handle_connection(conn)
sys.exit(0)

Running ps -ef results in a slew of '[ python <depreciated]' entries
(or something similar, I no longer have the actual output).

Will these clean themselves up if I leave the process running, and
what causes these?

Thanks in advance, G
Dec 28 '07 #1
1 1779
En Thu, 27 Dec 2007 21:36:36 -0300, Falcolas <ga******@gmail.comescribió:
This may be more of a Linux question, but it relates to how Python
forks...
Yes; every book describing how to use fork tells about zombie processes
and the wait/waitpid functions. Just do the same thing in Python.
Today, I implemented a pretty simple listener script using os.fork.
The script runs fine, and performs as expected, but the process table
is left with an odd entry for every fork called.
A "zombie".
I'm running on Slackware 9, under the 2.4 kernel, Python 2.5.1.

while True:
conn, addr = s.accept()
if os.fork():
continue
else:
handle_connection(conn)
sys.exit(0)
I'd try to use any of the existing server implementations in
SocketServer.py, but if you insist on using your own, look at the
ForkingMixin class as an example of using waitpid() to avoid having zombie
processes.

--
Gabriel Genellina

Dec 28 '07 #2

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

Similar topics

4
5885
by: Benoit Dejean | last post by:
hello, i have a question about forking processes atm, i have some code which i want to rewrite os.system("cd ~ && exec " + cmd + " & disown") i want to remove this os.system call
16
5785
by: mishra | last post by:
Hi, i thied the following code.. # include<stdio.h> int main() { int a; printf("Hello..."); a=fork(); printf("hi\n"); return(0);
27
5933
by: steve | last post by:
I was given the following code, and asked what the possible outputs could be. We're learning about processes and forking. int value; int main(){ int pid, number = 1; value = 2; pid = fork();...
11
8252
by: ramu | last post by:
Hi All, We know that a c function never returns more than one value. Then how come the fork() function returns two values? How it is implemented? Regards
3
2707
by: thrillseekersforever | last post by:
The questions(A&B) are to fine no# of process running from the below codes. However, I couldn't decipher the solution. Will someone please throw some light on this? Thanks a lot!! A] void...
5
12206
by: JoeW | last post by:
Now before I go into detail I just want to say that this is purely for my own benefit and has no real world usage. I remember way back when the tool for *nix systems called forkbomb was created. I...
4
2477
by: sc_wizard29 | last post by:
Hi everyone, One of my collegue at work said that on a 4 CPU server, it's better to write a program that forks 4 "sub-processes" instead of writing a single process program (ie : a program that...
4
1679
by: AK | last post by:
Hi everyone, Please check out this query that I have in : http://groups.google.com/group/progav/browse_thread/thread/29057ec587dd46b3 (its a bit long, thats why I am not typing it again;...
2
4225
by: Radz | last post by:
when the fork system call is executed, a new process is created. The original process is called the parent process whereas the new process is called the child process. The new process consists of a...
0
7223
marktang
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,...
0
7110
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7314
Oralloy
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,...
1
7030
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7482
tracyyun
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...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.