Lab Assignment--Signals


(Please do this lab in LINUX)

  1. The notes for this lab state that each signal has one of four default actions:

    Use the signal man page to find one signal that corresponds to each of these four actions. Find signals other than SIGKILL, SIGHUP, SIGWINCH, and SIGSTOP.

  2. For which two signals can you not change the default action?

    For both of these questions, put the answers in comments for the code that you will submit below

  3. Write a program that forks a child process. The parent will send a randomly generated signal to the child. The child will overwrite the default action of all the signals (1 to 31 inclusive) so that a message is displayed when the child receives a signal. The parent will also overwrite the default action of all signals. In the parent's signal handler, it will send a SIGKILL signal to the child. (Note: automatically, when a child exits, a SIGCHLD signal is sent to the parent)

    More Details:

Sample runs for question 3:

% ./run 
9: Invalid argument
19: Invalid argument
9: Invalid argument
19: Invalid argument
child waiting
child waiting
parent sending signal 3
Signal Received by child 3
child waiting
parent sending signal 3
Signal Received by child 3
child waiting
parent sending signal 8
Signal Received by child 8
child waiting
parent sending signal 9
Signal Received by parent  17
parent will exit now

%./run
9: Invalid argument
19: Invalid argument
9: Invalid argument
19: Invalid argument
child waiting
child waiting
parent sending signal 8
Signal Received by child 8
child waiting
parent sending signal 12
Signal Received by child 12
child waiting
parent sending signal 12
Signal Received by child 12
child waiting
parent sending signal 29
Signal Received by child 29
child waiting
parent sending signal 11
Signal Received by child 11
child waiting
parent sending signal 3
Signal Received by child 3
child waiting
^CSignal Received by child 2
child waiting
Signal Received by parent  2
Signal Received by parent  17
parent will exit now 

Deliverables:

Submit 2 files to URCourses

  1. code for this exercise
  2. Script containing two runs: