import os
print  "Before Forking" 
child = os.fork() #create a child process
print "After Forking\n"  
import os
pid = os.fork()
if pid == 0:
    print  "In child process"  # code to play animated GIF file
else:
    print  "In parent process"  #code to copy file 
         
import os
from multiprocessing import Process
if __name__ == '__main__':
    ppid=os.getpid()
    p = Process()
    p.start()
    cid = os.getpid()
  
if (cid):
    print ("Child : Hello I am the child process")
    print ("Child : Child’s PID: ", os.getpid( ) )
    print ("Child : Parent’s PID: ", os.getppid( ) )
else:
    print  ("Parent : Hello I am the parent process" )
    print  ("Parent : Parent’s PID: ", os.getpid( ) )
    print  ("Parent : Child’s PID: ", cid )
import os
pid = os.fork()
if pid == 0:
    os.execl ( "/bin/ls","-al", "/etc", NULL ) 
    print "Child: After exec( )"
else:
    print "Parent process"
import os
i = 0 
pid = os.fork( ) 
if ( pid == 0 ):
    while ( i < 4294967295 ):
        i=i+1
        print  "The child is now terminating" 
else:
    os.waitpid ( pid, status, 0 )
    if ( os.WIFEXITED ( status ) ):
        print  "Parent: Child terminated normally" 
    else:
        print  "Parent: Child terminated abnormally"