Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What does the following C program print [4 points] and why [7 points]? Note that emphasis of this question is on your understanding of the

What does the following C program print [4 points] and why [7 points]? Note that emphasis of this question is on your understanding of the signal functionality. State your assumptions where necessary.

pid_t pid;

void h1(int sig) {

printf("eagle");

kill(pid, SIGUSR2);

}

void h2(int sig) {

printf("sparrow");

exit(0);

}

main() {

signal(SIGUSR2, h1);

if ((pid = fork()) == 0) {

signal(SIGUSR2, h2);

kill(getppid(), SIGUSR2);

while(1) {};

}

else {

pid_t p; int status;

if ((p = wait(&status)) > 0) {

printf("pigeon");

}

}

}

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

Discuss why human resources managers need to understand strategy.

Answered: 1 week ago