#! /usr/bin/python3
"""Python example of fork() - wait() for CSCI 235"""

import os
import sys
import time

print("I am the parent with ID {0}.".format(os.getpid()))
PID = os.fork()

if PID == 0:
    print("I am the child with ID {0}.".format(os.getpid()))
    for x in range(3, 0, -1):
        print("Child counting down - {0}".format(x))
        time.sleep(1)
    print("Child {0} going bye bye!".format(os.getpid()))
    sys.exit(235)
    print("Should not get here")
else:
    print("I am the parent, waiting for {0}!".format(PID))
    WINFO = os.wait()
    print("Goodbye {0} with return {1} and status {2}.".format(
        WINFO[0], WINFO[1] >> 8, WINFO[1] & 255))
