Question: CODE IN C. AND SHOW THAT IT WORKS CORRECTLY AS THE PROBLEM STATES!!!! 2. Write a program that reaps dead children via a handler for

CODE IN C. AND SHOW THAT IT WORKS CORRECTLY AS THE PROBLEM STATES!!!!

CODE IN C. AND SHOW THAT IT WORKS CORRECTLY AS THE PROBLEM

2. Write a program that reaps dead children via a handler for SIGCHLD as follows (Refer procexec/multi SIGCHLD.c) :45 points FILE NAME: hw5_2.c Signal Handler for SIGCHLD a. This handler calls wait() to release dead child process ID b. Lengthen execution of handler using sleep() for 3 seconds - - Before fork(): c. Call signal() with the signal handler, signal Handler) d. Block SIGCHLD to prevent its delivery if a child terminates before the parent commences the sigsuspend() loop - Child Process e. f. g. Sleep as given by the inputs Print out child PID and current time Exit using_exit() -Parent Process h. Does nothing (i.e, just use break to escape oft of switch if you use it) After fork(): i. Replace the process signal mask by the empty signal set j. Suspend the parent process waiting for a SIGCHLD from the until all children are dead The program should be able to create any number of child processes with corresponding waiting time in second(s) such as $./hw5 2 1 2 34 5 (5 child processes with waiting times, 1, 2, 3, 4, and 5 seconds) $./hw5_2 15 10 2. Write a program that reaps dead children via a handler for SIGCHLD as follows (Refer procexec/multi SIGCHLD.c) :45 points FILE NAME: hw5_2.c Signal Handler for SIGCHLD a. This handler calls wait() to release dead child process ID b. Lengthen execution of handler using sleep() for 3 seconds - - Before fork(): c. Call signal() with the signal handler, signal Handler) d. Block SIGCHLD to prevent its delivery if a child terminates before the parent commences the sigsuspend() loop - Child Process e. f. g. Sleep as given by the inputs Print out child PID and current time Exit using_exit() -Parent Process h. Does nothing (i.e, just use break to escape oft of switch if you use it) After fork(): i. Replace the process signal mask by the empty signal set j. Suspend the parent process waiting for a SIGCHLD from the until all children are dead The program should be able to create any number of child processes with corresponding waiting time in second(s) such as $./hw5 2 1 2 34 5 (5 child processes with waiting times, 1, 2, 3, 4, and 5 seconds) $./hw5_2 15 10

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 Databases Questions!