Answer the question with C - language. Question. In the following code, assume that all function calls are successful. void sigusr1_handler(int sig) { } int main(void) { pid_t child; if ((child = fork()) == 0) { struct sigaction sa; sa.sa_handler = sigusr1_handler; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); sigaction(SIGUSR1, &sa, NULL); while (1) { printf("working ...\n"); sleep(1); } } else { //line 19 sleep(30); } // line 22 return 0; } (a) If you run the above program can it create either an orphan or a zombie process? Explain how. (b) Insert statements in only the part of the code related to the parent process (Lines 19–22) and function siguse1_handler() so that the child process would end after about 30 seconds of running. Clearly indicate where you insert any statements.
Answer the question with C - language.
Question.
In the following code, assume that all function calls are successful.
void sigusr1_handler(int sig) {
}
int main(void) {
pid_t child;
if ((child = fork()) == 0) {
struct sigaction sa;
sa.sa_handler = sigusr1_handler;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, NULL);
while (1) {
printf("working ...\n");
sleep(1);
}
}
else { //line 19
sleep(30);
} // line 22
return 0;
}
(a) If you run the above
how.
(b) Insert statements in only the part of the code related to the parent process (Lines 19–22)
and function siguse1_handler() so that the child process would end after about 30
seconds of running. Clearly indicate where you insert any statements.
thank you for your time
Step by step
Solved in 2 steps