This assignment is Due on: Day: Wednesday, May 13, 1998 Time: Not later than 6:00 PM WARNINGS: TURN IN THIS ASSIGNMENT ELECTRONICALLY USING "turnin". LATE ASSIGNMENTS WILL NOT BE ACCEPTED. ANY STUDENTS WHO SUFFER FROM SEVERE OR DEBILITATING FORMS OF HUMOR IMPAIRMENT ARE ADVISED TO SEEK HELP FROM A PROFESSIONAL COMEDIAN BEFORE ATTEMPTING THIS ASSIGNMENT. ---------------------------------------------------------------------- The purpose of this homework is to reinforce explanation of the following programming concepts: Use of signal(3c) Use of kill(2) Use of pause(2) Use of rand(3c) Read the material on signals on pp 383-390 in the Weiss book. Write a program that creates three child processes. As each child is created, have the parent print the following message to standard output: Go ahead, child process ..., make my day The ellipsis above must show the child's PID as returned by fork(2). Each child process must perform the following actions: 0. Install a Doterm() signal handling function (similar in structure to the Doexit() function shown on page 387 in Weiss). The Doterm() function must be called upon receipt of a SIGTERM by any child process, and must cause the following message to be printed to standard output: Child process ... feels lucky The ellipsis above must show the child's PID as returned by getpid(2). 1. Go into an infinite loop that waits for signals - the following statement: for( ; ; ) { ( void )pause( ); /* other loop stuff goes here */ } will do this in C. The parent must perform the following action: 0. Install a Docleanup() signal handler that will (upon receipt of a SIGTERM signal) send a SIGKILL signal to any child process that was created, but has not yet finished. Do not send the signals to child processes that have already terminated. After all the children have terminated, print the following message: A child process has got to know its limitations and then terminate. The program must consist of only the three functions Doterm(), Docleanup(), and main(), plus whatever other assorted global declarations (#includes, #defines, typedefs, variables, etc) are required. -----------------------Start Answer Here----------------------- [p0] 5.0 points Include the complete source code for all global declarations here. ------------------------End Answer Here------------------------ -----------------------Start Answer Here----------------------- [p1] 5.0 points Include the complete source code for your Doterm() function here. ------------------------End Answer Here------------------------ -----------------------Start Answer Here----------------------- [p2] 5.0 points Include the complete source code for your Docleanup() function here. ------------------------End Answer Here------------------------ -----------------------Start Answer Here----------------------- [p3] 15.0 points Include the complete source code for your main() function here. ------------------------End Answer Here------------------------ Write a program that will simulate a game of "hidden pebble" except that nuts get to take on a slightly more active role. The parent process begins by creating NUM_NUT child processes, where NUM_NUT is referred to as "nut") is created, it prints the following message: Nut ... created where the ellipsis is replaced by the nut's PID. The last nut created then randomly chooses one of the nuts to hide the pebble and gives it the pebble by sending it a SIGUSR1 signal. (It is valid for the last nut to choose itself.) The nut that has the pebble then prints: < Nut ... has the pebble > The last nut then sends a SIGUSR1 signal to the parent process to let it know it's time to guess. When the parent receives the signal, it selects a nut at random and prints: Parent chooses nut ... and then sends a SIGUSR2 signal to the chosen nut. If the nut that receives the signal has the pebble, it will send a SIGUSR1 back to the parent. If not, it will send a SIGUSR2 to the parent. The parent then prints either: I won! or I lost depending on which signal it received. In either case, after printing its final message, the parent smashes (kills) all the nuts and exits. -----------------------Start Answer Here----------------------- [p4] 20.0 points Include the complete source code for your "tag" game here. ------------------------End Answer Here------------------------