Question: Now modify the code of prog5.c to make it do the following: a) Have the child process return a value of 75 (to simulate that

 Now modify the code of prog5.c to make it do the
following: a) Have the child process return a value of 75 (to

Now modify the code of prog5.c to make it do the following: a) Have the child process return a value of 75 (to simulate that it encountered a database connection issue). b) Have the parent process detect that it returned a non-zero value by printing it. The output of prog5.o should look something like: I am the parent process (PID: 3852). I created a child process with PID 3853 I am the child process (PID: 3853). Unable to open connection to database I am the parent process (PID: 3852). Status of child process is 75 nain of process with PID 3852 ends Note that you have to use wait: int status = 0; wait(&status); And to print the value of status you can use the WEXITSTATUS macro: WEXITSTATUS(status) Include prog4.c and a snapshot of the output with you submission. #include #include #include int main(int argc, char* argv[]) { int retval = fork(); int mypid; if(retval == 0){ //the child process mypid = getpid(); //Assume tyhe child process is doing some complicated //computation that takes 5 seconds sleep(5); printf("I am the child process(PID: %). Done with my workin", mypid); }else if(retval > 0) { //The parent process mypid = getpid(); printf("I am the parent process(PID: %d). I created a child process with PID %d ", mypid, retval); }else{ //call to fork failed fprintf(stderr, "Error while calling fork "); wait(NULL); printf("main of process with PID %d ends ", mypid); return 0

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!