CS 284 Operating Systems
Programming Assignment #3

Due: 1/29/2001 - Class Time

Write a C program that accepts 1 integer command line argument that specifies how many times your program should print a message in response to cntl-C.  After the specified number of messages the program should revert to default behavior when receiving cntl-C.

You should perform the following tasks:

  1. Determine if the system that you are using resets the signal disposition each time a signal is handled.  Include your finding in the program description
  2. Write a main(. . .) that accepts an integer command line argument (iCount), stores the value in a location accessable to the handler, uses SIGNAL(. . . ) to install the handler for SIGINT, and then loops forever.
  3. Write a handler for SIGINT that writes a message the 1st iCount number of times that SIGINT occurs.  After iCount times the handler takes itself out of the handling business.
=================================================================

You will use the 'script' command to capture all necessary information for handin.  You do that by
starting the script command "script myHandin3"
cat your source.c program
run your program
exit
Remove the cntl-Ms from the script file.
a2ps myHandin3  |  lpr -P yourPrinterPreference

==================================================================
Alternate way to remove cntl-Ms (or any specific bytes from your file)

cat prog3.c | tr "\r" " " > new_prog3.c        //tr is a translate utility.  \r is == cntl-M
if new_prog3.c is OK
    {rm prog3.c
     mv new_prog3.c prog3.c
    }