[Tutor] forking process with python
Jimmy verma
jim_938 at hotmail.com
Sun Aug 17 05:20:55 EDT 2003
Hello,
I am having a problem in understanding this example from the o'rellys book
for python programming.
#!/usr/bin/python
def counter(count):
for i in range(count):
time.sleep(10)
print '[%s]--> %s ' %(os.getpid(), i)
for i in range(10):
pid = os.fork()
if pid != 0:
print 'Process %d spawned' %pid
else:
counter(10)
os._exit(0)
print 'Main process exiting.'
I am not getting how this os.fork is working as when the child process will
be created, when the pid will be zero.
As far i can understand is that fork returns the pid of the parent and 0 as
the return value for the child process( am i right ?).
Kindly suggest sthing regarding the working of this example.
If we have some links on the internet from where i can get information
related to forking process with python, pls point me towards that also.
Thanks to all.
Regards,
Jim
_________________________________________________________________
MSN Hotmail now on your Mobile phone.
http://server1.msn.co.in/sp03/mobilesms/ Click here.
More information about the Tutor
mailing list