Lab Assignment--Signals


(Please do this lab in LINUX)

Part 1: Questions

Write the answers to the following questions as comments at the beginning of your code.

  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 SIGILL, SIGHUP, SIGWINCH, and SIGSTOP.

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

Part 2: Code

Write a program that forks a child process. The parent will send SIGUSR1 to the child. The child will overwrite the default action of SIGUSR1 so that a message is displayed and the child exits. Without using wait(), the parent will exit after the child has exited. (Note: automatically, when a child exits, a SIGCHLD signal is sent to the parent)

More Details:

Sample run for the code:

% a.out
child waiting
child waiting
child waiting
child waiting
child waiting
child waiting
child waiting
...
child waiting
child waiting
child waiting
child waiting
child waiting
child waiting
Signal Received  10
parent waiting
...
Child received signal
parent waiting
parent waiting
parent waiting
parent waiting
parent waiting
parent waiting
parent waiting
...
Signal Received  17
Parent received signal

Deliverables: