Question: 3. Compile and run the program below. Complete the missing information in the diagram given after the code. Identify the parent process for P1. Identify

3. Compile and run the program below. Complete the missing information in the diagram given after the code. Identify the parent process for P1. Identify the parent process for P2. What are the possible different outputs for this program? int main() int pid; pid -fork ); if (pid - 1) perror ("ERROR - fork "); exit (0); else if (pid 0) printf ( "child process with pid- %d, and Parent pid- %d ", getpid ), getppid()) sleep (5); printf ("After sleeping. Child process with pid- %d, and Parent pid = %d ", getpid(), ge tppid()); exit (0); else printf ("Parent process with pid getpid , getppid))i printf ("Parent exiting now ") exit (0); ed, and Parent pid- %d ", return 0; P1 P2 PID- PPID- Value Returned by fork()- PID= PPID- Value Returned by fork)- Fork
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
