Question: Example 2: Parent and Child print different things #include #include #include int main(void) { pid_t childpid; childpid = fork(); if (childpid == -1) { perror

 Example 2: Parent and Child print different things #include #include #include

Example 2: Parent and Child print different things #include #include #include int main(void) { pid_t childpid; childpid = fork(); if (childpid == -1) { perror ("Failed to fork"); return 1; } if (childpid 0) /* child code */ printf("I am child %d ", (long) getpid()); else /* parent code */ printf ("I am parent %d ", (long) getpid()); return 0; == } a) What are the possible values returned from fork? b) Which process prints first, parent or child

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!