Question: Using the program in FIG 3 , identify the value printed at line A , B , C , and D . ( Assume that

Using the program in FIG 3, identify the value printed at line A, B, C, and D.
(Assume that the actual system process ID of the parent is 2222 and the child is 1111)
Possible values
A - pid ______1111 or 2222 or 0
B - pid1______1111 or 2222 or 0
C - pid ______1111 or 2222 or 0
D - pid1______1111 or 2222 or 0
FIG 3
int main(void)
{
pid_t pid , pid1;
pid = fork(); // fork a child process
pid1=0;
if (pid <0)// error
{
fprintf(stderr, "Fork Failed");
return 1;
}
else if (pid ==0)// child
{
printf("pid =%d
", pid); // A
printf("pid1=%d
", pid1); // B
}
else //parent
{
wait(NULL);
printf("pid =%d
", pid); // C
printf("pid1=%d
", pid1); // D
}
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!