title: How to call different functions with os.fork() in loop?
body: <p>I tried using following code</p>
  
  <pre><code>import os
  
  
  def sum1(a):
      print "We are in the child process with PID= %d"%os.getpid()
      for j in range(100000000): 
          m=j
      print "Sum: ",sum(a)
  
      os._exit(0)
  
  
  
  def mul(a):
  
      print "We are in the child process with PID= %d"%os.getpid()
      k=1
      for j in range(100000000): 
          m=j
      for i in a:
          k=k*i
      print "Multiplication: ",k
  
  def parent(a):
      while True:
          print "We are in the parent process with PID= %d"%os.getpid()
          newpid=os.fork()
  
          if newpid == 0:
              sum1(a)
  
          else:
              mul(a)
          if input() == 'q': break
  
  a=[12,12,12,12]
  parent(a)
  </code></pre>
  
  <p>But here in this code it creates forked process for only one function [ sum1() ] . I want to execute fork process in loop with calling different function each time. For example I want to call below three functions with different forked process in loop</p>
  
  <pre><code>def f1(a):
      print a
  def f2(b):
      print b
  def f3(c):
      print c
  </code></pre>
  
  <p>something similar to </p>
  
  <pre><code>for i in range(3):
      pid = os.fork()
      if pid == 0:
         f1(a) # then call f2(b) in next iteration and then f3(c)in last iteration
         os._exit(0)
  </code></pre>