Question: Assume the code in FIG 1 ( below ) is submitted for execution. What will the code output? A . H 1 END B END

Assume the code in FIG 1(below) is submitted for execution. What will the code output?
A. H1 END B END B H2 END A
B. H1 END B H2 END B H2 END A
C. H1 END A H2 END B END A
D. None of the others.
FIG 1
int main( void)
{
pid_t pid , pid1;
pid = fork(); // fork a child process ASSUME FORK was SUCCESSFUL
if (pid ==0)
{
printf("H1");
}
else
{
wait(NULL);
pid = fork (); // fork a child process ASSUME FORK was SUCCESSFUL
if (pid >0)
{
wait(NULL);
printf("H2");
}
}
If (pid >0)
printf("END A ");
else
printf("END B ");
return 0;
}

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