Question: Assume a process (Process 1) runs the below code. Stdin, stdout, and stderr are in their usual locations in the open file table. The child
Assume a process (Process 1) runs the below code. Stdin, stdout, and stderr are in their usual locations in the open file table. The child is Process 2.
What does Process 1s open file table look like right after executing the line marked as ***** Location #1?
Do the same for Process 2 immediately after it would execute the line with ***** Location #2. Fill in the table. Assume all functions complete successfully.
Code:
#include
int main() { FILE *fp1 = fopen("a.dat", "w"); if (fork() == 0) { fprintf(fp1, "What's up? "); FILE *f = fopen("b.dat","w"); pid_t pid = getpid(); fprintf(f, "The pid is %d ", pid); /* ***** Location #2 */ fclose(f); fclose(fp1); exit(EXIT_SUCCESS); } fprintf(fp1, "Hello!! "); /* ***** Location #1 */ fclose(fp1); wait(NULL); exit(EXIT_SUCCESS); }

# R? RW? Or W? Object Process 1 (aka parent): Process 2 (aka child): # R? RW? Or W? Object Process 1 (aka parent): Process 2 (aka child)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
