#############################################
# https://maths.nuigalway.ie/~gettrick/teach/cs211/
#############################################
import os, sys, time
def myloop(a,b):
# The process which we NAME b sleeps for a seconds
    for k in range(a):
        time.sleep(1)
        print (b, ' still alive, process ID: ', os.getpid())
# Now lets create the child process:
code = os.fork()
if code == 0:
# Now lets create a "grandchild" process:
    ncode = os.fork()
    if ncode == 0:
        myloop(5,'grandchild')
    else:
        myloop(10, 'child')
else:
    myloop(15,'parent')

