Problem with fork
Arief
stefanus.arief at ai.astra.co.id
Sun Oct 20 23:19:02 EDT 2002
Hi all,
There is something I don't understand. I've create simple program below in
my Linux:
#### START OF PROGRAM ####
#!/usr/bin/python
#
# MAIN PROGRAM
#
import os, sys, time
if os.fork(): sys.exit()
os.setsid()
for child in range(10):
time.sleep(1)
print 'Parent fork'
if not os.fork():
# Child process
print 'Child start:', child
time.sleep(child)
print 'Child exit:', child
sys.exit()
print 'Parent exit'
#### END OF PROGRAM ####
Parent creates 10 childs in sequence by fork. It works ...
But, everytime the child process exits, it leaves <defunct> in my process
status.
Can anyone help me with the solution?
Thanks,
-----
Arief
More information about the Python-list
mailing list