Question: 3.0 Process system calls fork(), execvp() and wait() system calls 1. Compile and run the following C code /15 2 #include 3 #include 4

3.0 Process system calls fork(), execvp() and wait() system calls 1. Compile and run the following C code /15 2 #include 3 #include 4 #include 5 #include 6 7 main() 8 { 9 int 10 11 12 13 14 15 16 fork_rv; printf("Before: my pid is %d ", getpid()); fork_rv fork(); if (fork_rv == -1) {perror("fork"); } /* create new process /* check for error 17 18 if (fork_rv == 0 ) 19 { 20 21 } 22 printf("My PID is %d ", getpid()); printf("I am waiting for my child %d ", getpid()); 23} a. What is the purpose of this code? b. Use strace -c to identify the system calls used by this program. Attach the screen capture that displays the system calls. Explain the purpose of the different fork( ) system call output values: 0 -1 >0 c. Identify child process and parent process code and modify the program using sleep() and wait() system calls so that the child process sleeps for 5 seconds and the parent waits for the child to complete its task. d. Attach modified code and results
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
