python fork error

37

import os

def _fork():
   raise OSError()
os.fork = _fork

for i in range(1,4):
    try:
         pid = os.fork()
    except OSError:
         print ("Error forking process")
         continue
    if pid == 0:
         print "In child process"
         os._exit(0)
    print "In parent process"
for i in range(1,4):
    try:
         pid = os.fork()
    except OSError:
         print ("Error forking process")
         continue
    if pid == 0:
         print "In child process"
         os._exit(0)
    print "In parent process"

Comments

Submit
0 Comments