Question: 2. Write a program that reaps dead children via a handler for SIGCHLD as follows (Refer procexec/multi_SIGCHLD.c) - Signal Handler for SIGCHLD : a. This
2. Write a program that reaps dead children via a handler for SIGCHLD as follows (Refer procexec/multi_SIGCHLD.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. Sleep as given by the inputs f. Print out child PID and current time g. 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 3 4 5 (5 child processes with waiting times, 1, 2, 3, 4, and 5 seconds) $ ./hw5_2 1 5 10 * *
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
