Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8 . ( 1 0 pts . ) Consider the following C program. ( For space reasons, we are not checking error return codes, so

8.(10 pts.) Consider the following C program. (For space reasons, we are not checking error return
codes, so assume that all functions return normally.)
pid_t pid;
void handler1(int sig){
printf("B
");
fflush(stdout); // flush to stdout
kill(pid, SIGUSR2);
}
void handler2(int sig){
printf("C
");
exit(0);
}
main(){
signal(SIGUSR1, handler1);
signal(SIGCHLD, handler2);
if ((pid = fork())==0){
signal(SIGUSR2, handler2);
kill(getppid(), SIGUSR1);
// getppid() returns parents pid
while(1){};
}
else {
pid_t p; int status;
if ((p = wait(&status))>0){
printf("A
");
}
}
}
Draw the process model and identify the string(s) output by each process.
What is the output generated by this program? Are different orders possible?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions