#!/bin/perl
# File: fork1

# Demonstrate a parent creating a child who finishes before the parent.

# Call fork to create a child process
if (fork == 0) {   # Child branch
   print "I am the child.\n";
   exit(0);        # End of child
}
else {             # Parent branch
   print "And I am the parent.  I will sleep for 2 seconds.\n";
   sleep(2);
   # system("ps -f");    # UNCOMMENT THIS LINE
   print "I am the parent and I am awake now.  G'day!\n";
}  # End of parent
