Question: Operating Systems Programming question: (35 points) A parent process and a child process use kill() and signal to communicate. Please use fork() to create the
Operating Systems Programming question:
(35 points)
A parent process and a child process use kill() and signal to communicate. Please use fork() to create the child process from the parent. After that, the parent process can then send the following signals to the child process using kill():
SIGHUP: hang-up (death) on controlling terminal (process) (Default action: abnormal termination)
SIGINT: interactive attention signal (usually Ctrl-C) (Default action: abnormal termination)
SIGQUIT: interactive termination: core dump (Default action: implementation dependent)
The parent process can sleep() some time (for example, 5 seconds) after sending each signal.
The child process:
After receiving SIGHUP: output I have received SIGHUP;
After receiving SIGINT: output I have received SIGINT;
After receiving SIGQUIT: output I have received SIGQUIT, and terminate.
Here is the pseudocode for this program:
A list of functions defining the actions associated with signals
Main()
1. Create the child process;
2. if (child process)
{
Use signal() or sigaction() to specify the action associated with the signal;
Infinite loop;
}
3. if (parent process)
{
Send SIGHUP to the child process;
Sleep some time;
Send SIGINT to the child process;
Sleep some time;
Send SIGQUIT to the child process;
Sleep some time;
}
For more examples, please refer to Chapter 8 of the following textbook:
Unix System Programming, K.A. Robbins and S. Robbins, Prentice Hall, ISBN: 0-13-042411-0, 2003
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
