Question: 1 . Consider the following C program. ( For space reasons, we are not checking error return codes, so assume that all functions return normally.

1. 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
");
kill(pid, SIGUSR2);
}
void handler2(int sig){
printf("C
");
exit(0);
}
int 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;
printf("A
");
if ((p = wait(&status))>0){
printf("D
");
}

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