OPS102
John Sellens
john.sellens@senecapolytechnic.ca
Home UNX511 Help Notes Contact

Lab 5b - Week 6 - Signals

Due: Sunday June 22

FIRST: See labs.html for information on labs.

Copy the lab 5b sample code from https://github.com/jsellens/unx511_samples/tree/main/lab_5b (or clone/update the unx511_samples repository).

In this lab you will use signals as a method of communication between a parent process and its children processes. Signals will be used to synchronize the start-up and shutdown of all children processes.

The particular application in mind is a network monitor. The parent will start up children to monitor the network interfaces on a machine. In our case, there are two interfaces: ens33 and lo. There will therefore be two children. One child will monitor ens33 and one child will monitor lo.

The parent process (sysmonExec) will spawn two children (intfMonitor) as follows:
$ ./intfMonitor lo
$ ./intfMonitor ens33

For the parent, you will have to send the start signal (SIGUSR1) to the children, sleep for 30 seconds, then send the stop signal (SIGUSR2) to the children. The parent should wait for all children to shutdown before shutting itself down.

For the child, you will have to register signal handlers for start-up (SIGUSR1), shutdown (SIGUSR2), ctrl-C and ctrl-Z. For ctrl-C and ctrl-Z, your signal handler will simply discard them, meaning your program will not shutdown on ctrl-C nor be put in the background on ctrl-Z. Your child will have to wait until it receives a start signal from the parent before starting. The child's signal handler will handle 4 signals as follows:

When the child receives the shutdown signal, it should stop processing and exit.

Code has been given to you so you can concentrate on the signals portion only. Simply fill in the parts indicated by TODO.

The files are Makefile sysmonExec.cpp and intfMonitor.cpp

Lab Submission:

See the lab 5b submission instructions in labs.html



UNX511 NSB Class Links

References

Tools

Links





|Home|UNX511|Help Notes|Contact|


Last modified: 2025-06-12 01:42:15 -- Last formatted: 2025-06-12 02:01:01
john.sellens@senecapolytechnic.ca