Unix Systems Programming: Lab 4 - Processes & Signals, Signal Processing
Due: Wednesday, May 2, 2012 @ 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.
Recources
FAQ
(submission instructions and other useful stuff)
Please reviews lecture4 notes carefully,
for each
part of lab, there is also specified reading assignment.
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
All work should be done on a machine in the department's
Linux cluster. You can refer to ssh for
more
information on
how to log into a remote machine.
Marks Distribution
Part 1 |
13 points |
Part 2 |
13 points |
Part 3 |
14 points |
TOTAL |
40 points |
LAB 4
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:
- You should accumultate 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?"
- 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).
- 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 follow these steps to finish this part
smoothly:
- Read "signal" sessions in textbooks as per the syllabus.
- Read and understand the example code first.
- Understand that handling SIGUSR1 is one of the most
primitive forms
of interprocess communication in Unix (i.e., you are communicating with
another
process).
Deliverables
Carefully follow the steps below.
- Use svn update to bring your svn repository to the latest version and navigate to the lab4 directory. Place all your work in this directory. You are free to organize your source files however you like. Your directory should contain at least two files:
- One or more source files
- A makefile. This should produce the executable mysig when we type make on the command line.
- When you are finished with your assignment, you should commit it to the repository using the following commands:
svn add *
svn commit -m "Submitting Lab 4"
- Your submissions will be collected from the repository on Wednesday, May 2nd at 5 PM