# creating and demonstrating an orphan process
import os
import time
id = os.fork()
if (id==0): # this is the child
   parent = os.getppid()
   for j in range(7):
      time.sleep(1)
      cppid=os.getppid()
      print ("Child: My parent is process ID ", cppid)
      if (parent != cppid):
         parent = cppid
         print ("I just became an orphan")
         print("I was adopted by new parent process ", os.getppid())
         #print("I was adopted by new parent process ", cppid)
else: # this is the parent
   time.sleep(3)
