Unix Systems Programming: Lab 4 - Processes & Signals, Signal Processing

Due:           Friday, February 3, 2017 @ 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 6 points
Part 2 6 points
TOTAL 12 points

LAB 4

Part 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:

  1. 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?" 

  2. 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).

  3. 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.
  4. Please follow these steps to finish this part smoothly:

Part 2 - Shell

Congratulations!  You are going to write your own simple Unix shell -- the "gosh" shell (Grand Ole SHell)

The purpose of this part is to write your own shell in C.  This simple project is designed to give the programmer a working knowledge of input string processing and basic fork/exec procedures.

We have provided you with a simple shell template that you can choose to work from.  You can compile the shell using the following command assuming you've untarred the package and entered the gosh_template subdirectory:

gcc -I./ gosh_template.c -o gosh

  Each step will define a test that you can run and expected behaviour.  Please make your shell follow this behaviour.

Deliverables

Carefully follow the steps below.

    1. You are free to organize your source files however you like ("Part1" and "Part2" might make sense). Your directories should contain at least two files:

    2. When you are finished with your directory you will create a compressed archive file using tar (this utility stores your directory as a single file, then compresses its size.)
             tar -czvf   username.lab4.tgz   username.lab4

    3. You will email your file to our TA as an attachment. He will send an acknowledgement that your assignment has been received.

    4. To  Nicholas Flees (nickflees@uchicago.edu)
      Attachment  username.lab4.tgz
      Subject  CSPP51081-lab4