Question: To complete the signals - based chat program described above, do the following. We recommend doing them in order. Each is described in more detail

To complete the signals-based chat program described above, do the following. We recommend doing them in order. Each is described in more detail below.
Note the above instructions regarding testing on portal.
I would recommend working in pairs on this lab, but note that both instances of the chat program need to run as the same user. (You cant send signals to another users programs.)
Start with the template program below that prints out its PID and reads in another PID into a global variable.
As described below, the template program sets up access to two shared memory regions:
my_inbox which is this processs inbox for chat messages;
other_inbox which is the other processs inbox for chaat messages.
Your code will write to other_inbox and read from my_inbox.
Create a signal handler for the SIGINT, SIGTERM, and SIGUSR1 signals
SIGTERM should invoke cleanup_inboxes and then exit
SIGINT should invoke cleanup_inboxes and then send SIGTERM to the other user and then exit
SIGUSR1 should display the contents of the inbox (eventually in shared memory; make a pointer to a placeholder character array for now) and then set its first character to be '\0'
(Although normally one should take care to only use signal-safe functions in your signal handlers, for this lab, we do not care if you follow this rule.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!