Question: #include #include using namespace std; int main(int argc, char* argv[]) { // pit_t id = fork(); if (id > 0) { // Block 1 }
#include
int main(int argc, char* argv[]) { // pit_t id = fork(); if (id > 0) { // Block 1 } else if (id < 0) { // Block 2 } else { // Block 3 } return 0; }
The goal for the code following the fork() statement is as follows:
1. The program must display an error message if process creation is not successful
2. The parent process must wait for the child process to be done and then return
3. The child process must switch to a different program based on what is passed in the argv array
To achieve this goal, appropriate code must be put into the regions marked as "Block 1", "Block 2" and "Block 3".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
