Write a C program called signal.c that responds to the SIGINT signal. The program should consist of a for loop that executes 20 or 30 times. Each pass through the loop the program should print out "In loop, pass through loop is #" where # is the value of the loop iteration control variable. In addition, the loop should have a sleep delay of 1 second. The program should use a command line parameter to control how it responds to SIGINT. The program should be run assignal [option] where option can have the values i, c or d. The parameter values cause the program to do the following: i - the program ignores the SIGINT signal. c - the program catches SIGINT and prints out a message. It then resumes execution of the loop. d - the program terminates when it receives SIGINT.
How do I get started?
See the man pages for signals and sigaction, which controls how a program responds to a signal. The project is just a straightforward exercise to acquaint you with signals and event driven programming. Try sending the SIGINT signal to the program to make sure the program responds as specified. See the man pages on kill. You can also use the ctrl c keys.
What do I hand in?
(1) You must hand in a hard copy of the source code with your name in a comment on the first line. Please do not hand in any output. You can print your program in the Distributed Computing Lab (4301) with the command mpage -2 -f -P rw.c
(2) Leave a copy of your program in your directory in a file named signal.c.
When is the project due?
The project is due Tuesday, October 22. Projects will not be accepted after the due date.