Question: #include (sys/types.h #include (unistd.h> #include (stdio.h> #include (stdlib.h int g 2 int mairkvoid) pid t pid nt 3: printf(precessid(%d): Parent gs %d, 15%din.. 9etpido. 9,

 #include (sys/types.h #include (unistd.h> #include (stdio.h> #include (stdlib.h int g 2

#include (sys/types.h #include (unistd.h> #include (stdio.h> #include (stdlib.h int g 2 int mairkvoid) pid t pid nt 3: printf("precessid(%d): Parent gs %d, 15%din.. 9etpido. 9, Q: perror(fork error) exit(l) ) else if(pid ss 0) 9142 printfC"I am a new child and my procedd id is: d In".getpidO) printf("My parent process id is: %dVn", getPpid0 printfC In The child process now terminates") else( 99 100: 1-300; printf(T am the PARENT process cnd my procedd idis %dVn". getpid0k printf("Parent process id of the Parent Process is: %d le", getppidr printfC'In The parent process now terminates) printf(" nin printf("Vin Whe Am I ?? gd) 9'ld, l. %dV,-. get-d). 9. I): //statement ^ whe is my parent ?? (%d): ". gefppid()): //statement B refurn O, Compile and run fork test.e. Answer the following questions (a) What are the process IDs of the parent and the child processes b) Type ps from the shell prompt and identify process ID of the nonloginlogin) shell. What is the parent process ID of the parent process? (c) What are the values of the variables g and I of the parent process and the child process created by the fork respoctively d) Show the output printed by the statements A and B, explain why you get the result

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!