Lab Assignment--Signals


Lab Code

To get the sample and exercise code, please use the following commands in your cs330 directory:
   curl -O -s https://www.labs.cs.uregina.ca/330/Signals/Posix/Lab10.zip
   unzip Lab10.zip

(Please do this lab on os1 or os2)

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 (not including continue):

    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 SIGWINCH to the child. The child will override the default action of SIGWINCH 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 28 
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: