Section 1 Write a program in C/C++ that: • Spawns two processes. • Each process
ID: 3676438 • Letter: S
Question
Section 1
Write a program in C/C++ that:
• Spawns two processes.
• Each process executes an infinite loop and waits for the parent process to send them a signal.
• After 5 seconds, the parent sends the signal SIGINT to both children.
• Upon receiving the signal, the children print their own pid and the pid of the parent and terminate.
Section 2
Modify the program from Section 1 so that upon receiving the signal:
• the first child process, lists all the elements in the “/home” directory
• the second child process, sends a SIGQUIT signal to the parent
• when the parent receives the SIGQUIT signal it prints the message “Now I have to terminate” and exits. The parent should not terminate otherwise.
Section 3
Write a program that creates three processes and gets as an input from command line an integer number N (N > 10).
• The first process prints the numbers [0, N/3) continuously (the process should never finish).
• The second process prints the numbers [N/3, 2N/3) continuously (the process should never finish).
• The third process prints the numbers [2N/3, N] continuously (the process should never finish).
• After 5 seconds the father should send a SIGKILL signal to the three children.
Explanation / Answer
///////////////////////////////////////////////////////////////////////////////////
section 3:
SIGINT Terminate process Terminal line hangup
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.