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

import os
import sys

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

if PID == 0:
    BOOTYGRUBY = "/boot/grub"
    print("I am the child with ID {0}.".format(os.getpid()))
    print("I want to list {0}".format(BOOTYGRUBY))
    os.execv("/bin/ls", ["ls", "-l", BOOTYGRUBY])
    print("You don't belong here")
    sys.exit(235)
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))
