Unix Systems Programming: Lab 4

Due:           Wednesday, October 27, 2010 @ 5:00 pm.  



 PURPOSE AND RATIONALE

The purpose of this lab is to allow students to become comfortable with signal handling and processing in Unix.

PRIMARY RESOURCES:

FAQ (submission instructions and other useful stuff)

You should refer to the required reading sections of the assigned texts in order to accomplish this lab.

If possible, you should ssh into the cluster to perform all lab activities.   

README

  1. If you are not in our course email list, please subscribe to the cspp51081 email list here: http://mailman.cs.uchicago.edu/mailman/listinfo/cspp51081 ;
  2. Before starting, please reviews lecture4 note carefully, for each part of lab, there is also specified reading assignment;
  3. Please pay attention to "DELIVERABLES" instruction in each part;
  4. Turn the lab assignment in by email to the grader by the due date.

LAB 4

  1. Signal Handling


    Write a signal handler that catches the CTRL-C (SIGINT signal 2) and SIGUSR1 (signal 10) signals.   Your process should not by default exit on CTRL-C back to your shell.  You may want to look on the BLP example on signals, or Chapter 6 of Molay's text if you're using that.  The following requirements apply:

  2. You should accumulate the handling of CTRL-C in the handler.  That is to say, you should have a variable counter accumulate each time the handler is called, and print out the current count in the handler.  For instance, if you've hit CTRL-C 6 times, your handler should print out something to the effect of "You've pressed Ctrl-C 6 times.  Aren't you getting the message that I'm invulnerable?"  
  3. Your program should accept a command line argument that specifies the MAXSTOPS allowed, after which, Ctrl-C is handled in the default way (i.e., the program terminates).  So if the user passes in '10' on the command line, the program prints out it's message above the first 9 times, but the 10th time CTRL-C is pressed, the default action applies (program termination).
  4. You should print out a message that states that your program received the SIGUSR1 signal when it is handled.  You should be able to issue a kill command to send your program the SIGUSR1 signal, and have that signal handled properly (by printing out a receipt notification) and then continue to function and handle subsequent CTRL-C and SIGUSR1 signals.

Please following these steps to finish this part smoothly:

DELIVERABLES: your source file(s) (e.g., my_sig.c), a makefile, and a README as described in the submission faq

    MARKS DISTRIBUTION

    1. Excercise 1:

    2. Total Marks: 25


    Atilla Soner Balkir