# import the os module
import os

# what to do as a child
def child():
   print 'A new child ',  os.getpid( )
   print "Hit return to continue, q to quit."
   os._exit(0)  

# what to do as a parent
def parent():
   while True:
      newpid = os.fork()
      if newpid == 0:
         child()
      else:
         pids = (os.getpid(), newpid)
         print "parent: %d, child: %d" % pids
      if raw_input( ) == 'q': break

parent()

##############################################################################